Contents

endWith operator in RxJs

Updated on 2021-02-09

endWith Operator

Can be imported from here:

1
2
3
import { endWith } from 'rxjs/operators';
// or
const { endWith } = require('rxjs/operators');

For official documentation, visit https://rxjs-dev.firebaseapp.com/api/operators/endWith

Returns an observable that emits after the source completes.

1
2
3
4
5
6
7
import { of } from 'rxjs';
import { endWith } from 'rxjs/operators';

const source$ = of('hi', 'how are you?', 'sorry, I have to go now');
const result$ = source$.pipe(endWith('goodbye!'));
 
result$.subscribe(word => console.log(word));
1
2
3
4
hi
how are you?
sorry, I have to go now
goodbye!

Комментарии