finalize

/**
 * 语法
 * @param {Function} callback -回调函数
 * @return {Function}
 */
finalize(callback);

订阅源并且当源发出CompleteError时将调用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("结束了")));