Last active
September 21, 2015 20:48
-
-
Save mattpodwysocki/79b82b9d18030be2c494 to your computer and use it in GitHub Desktop.
Why scheduling matters with RxJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rx.Observable.fromArray([1,2,3], Rx.Scheduler.currentThread) | |
.flatMap(function (x) { | |
return Rx.Observable.repeat(x, x); | |
}) | |
.subscribe(function (x) { | |
console.log('Next: %s', x) | |
}); | |
// => Next 1 | |
// => Next 2 | |
// => Next 2 | |
// => Next 3 | |
// => Next 3 | |
// => Next 3 | |
Rx.Observable.fromArray([1,2,3], Rx.Scheduler.immediate) | |
.flatMap(function (x) { | |
return Rx.Observable.repeat(x, x); | |
}) | |
.subscribe(function (x) { | |
console.log('Next: %s', x) | |
}); | |
// => Next 1 | |
// => Next 2 | |
// => Next 3 | |
// => Next 2 | |
// => Next 3 | |
// => Next 3 | |
Rx.Observable.fromArray([1,2,3], Rx.Scheduler.default) | |
.flatMap(function (x) { | |
return Rx.Observable.repeat(x, x); | |
}) | |
.subscribe(function (x) { | |
console.log('Next: %s', x) | |
}); | |
// => Next 1 | |
// => Next 2 | |
// => Next 2 | |
// => Next 3 | |
// => Next 3 | |
// => Next 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment