Efficient-angular
GitHubToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto modeBack to homepage

TakeLast

Waits for the source to complete, then emits the last N values from the source, as specified by the count argument.

Syntax

takeLast<T>(count: number): MonoTypeOperatorFunction<T>
ParametersDescription
countThe maximum number of values to emit from the end of the sequence of values emitted by the source Observable.

Returns

MonoTypeOperatorFunction: A function that returns an Observable that emits at most the last count values emitted by the source Observable.

Example

Take the last 3 values of an Observable with many values

import { range } from 'rxjs';
import { takeLast } from 'rxjs/operators';

const many = range(1, 100);
const lastThree = many.pipe(takeLast(3));
lastThree.subscribe(x => console.log(x));