This operator returns an observable containing a given number of contiguous data from the observable. It has the following signature:
The first parameter is mandatory and the last is optional:
- count: This is the number of elements to be retrieved from the observable
- scheduler: This is used to deliver the onCompleted() method in the case of the count equaling 0
The usage of this operator is really simple and can be seen in the following example:
Rx.Observable .of(1,3,5) .take(2) .subscribe((i)=>console.log(i));
In this example, we will take only the first two elements in the sequence, so running this code, we will see the following output:
This operation is illustrated ...