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?') );
Run Code Online (Sandbox Code Playgroud)
您也可以使用RxJS finalize
运算符,查看Documentation。finalize
当Observable完成或出错时执行。
例如:
finalize(() => console.log('Sequence complete')) // Execute when the observable completes
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
47 次 |
最近记录: |