when using tap we have 3 sections: event, error, complete.
the complete section will be triggered only if no error occurred on the way. is there a way to guarantee that the complete section will run no matter what (like finally in exception handling)?
tap(ev => console.log('event: ', ev)
err => console.log('error:', err),
() => console.log('guaranteed section?') );
You could alternatively use RxJS finalize operator, have a look at Documentation. finalize is executed when Observable completes or errors.
For example:
finalize(() => console.log('Sequence complete')) // Execute when the observable completes
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With