/**
* 语法
* @param {Function} callback -回调函数
* @return {Function}
*/
finalize(callback);
订阅源并且当源发出Complete
或Error
时将调用callback
函数
import { interval } from "rxjs";
import { finalize, take } from "rxjs/operators";
const source$ = interval(1000).pipe(take(3));
const result$ = source$.pipe(finalize(() => console.log("结束了")));