Learn RxJS
Search…
takeLast

signature: takeLast(count: number): Observable

Emit the last n emitted values before completion

πŸ’‘ If you want only the last emission from multiple observables, on completion of multiple observables, try forkJoin!
​​
​
​

Examples

Example 1: take the last 2 emitted values before completion
1
// RxJS v6+
2
import { of } from 'rxjs';
3
import { takeLast } from 'rxjs/operators';
4
​
5
const source = of('Ignore', 'Ignore', 'Hello', 'World!');
6
// take the last 2 emitted values
7
const example = source.pipe(takeLast(2));
8
// Hello, World!
9
const subscribe = example.subscribe(val => console.log(val));
Copied!

Additional Resources

Last modified 2yr ago