UNPKG

1.55 kBTypeScriptView Raw
1import { MonoTypeOperatorFunction } from '../types';
2/**
3 * Waits for the source to complete, then emits the last N values from the source,
4 * as specified by the `count` argument.
5 *
6 * ![](takeLast.png)
7 *
8 * `takeLast` results in an observable that will hold values up to `count` values in memory,
9 * until the source completes. It then pushes all values in memory to the consumer, in the
10 * order they were received from the source, then notifies the consumer that it is
11 * complete.
12 *
13 * If for some reason the source completes before the `count` supplied to `takeLast` is reached,
14 * all values received until that point are emitted, and then completion is notified.
15 *
16 * **Warning**: Using `takeLast` with an observable that never completes will result
17 * in an observable that never emits a value.
18 *
19 * ## Example
20 *
21 * Take the last 3 values of an Observable with many values
22 *
23 * ```ts
24 * import { range, takeLast } from 'rxjs';
25 *
26 * const many = range(1, 100);
27 * const lastThree = many.pipe(takeLast(3));
28 * lastThree.subscribe(x => console.log(x));
29 * ```
30 *
31 * @see {@link take}
32 * @see {@link takeUntil}
33 * @see {@link takeWhile}
34 * @see {@link skip}
35 *
36 * @param count The maximum number of values to emit from the end of
37 * the sequence of values emitted by the source Observable.
38 * @return A function that returns an Observable that emits at most the last
39 * `count` values emitted by the source Observable.
40 */
41export declare function takeLast<T>(count: number): MonoTypeOperatorFunction<T>;
42//# sourceMappingURL=takeLast.d.ts.map
\No newline at end of file