We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current Behavior Callbacks registered with finalizing operator are called in flipped order.
Reproduction Link to codepen
const problem1 = pipe( from([1,2,3]), finalize(() => log("1")), map(x => x * 2), finalize(() => log("2")) ) problem1.subscribe()
Current output
"2" "1"
Expected output This is what I expect. I would like to finalize previous things first before the things further down my chain.
"1" "2"
Environment
The text was updated successfully, but these errors were encountered:
The order in which the finalize operators are called depends upon several factors.
finalize
In your snippet, they are called in 'reverse' order because the source and the composed operators complete synchronously.
In this example, they are not called in reverse order because the source observable completes before the observable within the mergeMap:
mergeMap
import { asyncScheduler, from, of } from "rxjs"; import { finalize, mergeMap } from "rxjs/operators"; const problem1 = from([1,2,3]).pipe( finalize(() => console.log("1")), mergeMap(x => of(x * 2, asyncScheduler)), finalize(() => console.log("2")) ); problem1.subscribe();
Essentially, this behaviour is be design.
Sorry, something went wrong.
No branches or pull requests
Bug Report
Current Behavior
Callbacks registered with finalizing operator are called in flipped order.
Reproduction
Link to codepen
Current output
Expected output
This is what I expect. I would like to finalize previous things first before the things further down my chain.
Environment
The text was updated successfully, but these errors were encountered: