Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 2.21 KB

takelast.md

File metadata and controls

61 lines (47 loc) · 2.21 KB

Rx.Observable.prototype.takeLast(count)

Returns a specified number of contiguous elements from the end of an observable sequence, using an optional scheduler to drain the queue.

This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed.

Arguments

  1. count (Number): Number of elements to bypass at the end of the source sequence.

Returns

(Observable): An observable sequence containing the source sequence elements except for the bypassed ones at the end.

Example

var source = Rx.Observable.range(0, 5)
    .takeLast(3);

var subscription = source.subscribe(
    function (x) {
        console.log('Next: ' + x);
    },
    function (err) {
        console.log('Error: ' + err);
    },
    function () {
        console.log('Completed');
    });

// => Next: 2
// => Next: 3
// => Next: 4
// => Completed

Location

File:

Dist:

Prerequisites:

  • None

NPM Packages:

NuGet Packages:

Unit Tests: