RxJS - Filtering Operator last



This operator will give the last value emitted by the source Observable.

Syntax

last()

Return value

It returns an observable with the last value.

Example

import { of } from 'rxjs';
import { last } from 'rxjs/operators';

let all_nums = of(1, 6, 5, 10, 9, 20, 40);
let final_val = all_nums.pipe(last());
final_val.subscribe(x => console.log("The last value is = "+x));

The last() gives the last value from the list provided.

Output

last Operator
Advertisements