December 2015
Intermediate to advanced
144 pages
3h 37m
English
A Scheduler is a mechanism to "schedule" an action to happen in the future. Each operator in RxJS uses one Scheduler internally, selected to provide the best performance in the most likely scenario.
Let’s see how we can change the Scheduler in operators and the consequences of doing so. First let’s create an array with 1,000 integers in it:
| | var arr = []; |
| | for (var i=0; i<1000; i++) { |
| | arr.push(i); |
| | } |
Then, we create an Observable from arr and force it to emit all the notifications by subscribing to it. In the code we also measure the amount of time it takes to emit all the notifications:
| | var timeStart = Date.now(); |
| | Rx.Observable.from(arr).subscribe( |
| | function onNext() {}, |
| | function onError() {}, |
| | function ... |
Read now
Unlock full access