// RxJS v6+import { endWith, finalize } from'rxjs/operators';import { of } from'rxjs';constsource$=of('Hello','Friend');source$// emit on completion.pipe(endWith('Goodbye','Friend'),// this function is invoked when unsubscribe methods are calledfinalize(() =>console.log('Finally')) )// 'Hello', 'Friend', 'Goodbye', 'Friend'.subscribe(val =>console.log(val));// 'Finally'