function
stable
Skip the last count
values emitted by the source Observable.
skipLast<T>(count: number): MonoTypeOperatorFunction<T>
count | Number of elements to skip from the end of the source Observable. |
MonoTypeOperatorFunction<T>
: An Observable that skips the last count values emitted by the source Observable.
ArgumentOutOfRangeError
When using skipLast(i)
, it throws ArgumentOutOrRangeError if i < 0
.
skipLast
returns an Observable that accumulates a queue with a length enough to store the first count
values. As more values are received, values are taken from the front of the queue and produced on the result sequence. This causes values to be delayed.
Skip the last 2 values of an Observable with many values
import { range } from 'rxjs'; import { skipLast } from 'rxjs/operators'; const many = range(1, 5); const skipLastTwo = many.pipe(skipLast(2)); skipLastTwo.subscribe(x => console.log(x)); // Results in: // 1 2 3
© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/skipLast