Learn RxJS


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!


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

Additional Resources

Last modified 2yr ago