Schedulers exist so we can exercise more control over when subscription occurs and when values are observed. They also provide a mechanism we can hook to get more deterministic tests that run very fast.
A few issues with the current Scheduler set up
- It's hard to build a test suite for people.
- do we need a global default scheduler? Should we just pass one around?
- if an operator defaults to a particular scheduler, do we patch it to make it use a test scheduler during test scenarios?
- It's a large and complicated part of the library
- It's a little-understood part of the library
- Scheduler arguments aren't symmetric with proposed Observable APIs, like
Observable.of
- Still doesn't make it much easier to test things like
animationFrame or the like.
- When a scheduler is needed, it must be passed around and provided to every Observable creation call and time-related operator.
Questions
- In practice, is it better to have an
Observable.of(1, 2, 3, async) or Observable.asyncOf(1, 2, 3)? Observable.of(1, 2, 3, asap) or Observable.microtaskOf(1, 2, 3) (name totally bike-sheddable)
- Could we potentially just use
setTimeout or Promise then, and patch them temporarily at test time? It seems like that might make it easier to build test suites. It might also reduce the size of the library.
- How much do people really find the need to use Schedulers? How valuable are they if we found another way to deterministically test Observables?
- Would scaling them back a great deal reduce the size of the library significantly?
Other things
Having schedulers might enable us to centralize error handling in the next version, which could help performance and reduce library size. This was one of the central changes in "T-Rex".
NOTE: This is just a discussion to get us to question what we've been doing with schedulers, not a change suggestion per say
Schedulers exist so we can exercise more control over when subscription occurs and when values are observed. They also provide a mechanism we can hook to get more deterministic tests that run very fast.
A few issues with the current Scheduler set up
Observable.ofanimationFrameor the like.Questions
Observable.of(1, 2, 3, async)orObservable.asyncOf(1, 2, 3)?Observable.of(1, 2, 3, asap)orObservable.microtaskOf(1, 2, 3)(name totally bike-sheddable)setTimeoutorPromisethen, and patch them temporarily at test time? It seems like that might make it easier to build test suites. It might also reduce the size of the library.Other things
Having schedulers might enable us to centralize error handling in the next version, which could help performance and reduce library size. This was one of the central changes in "T-Rex".
NOTE: This is just a discussion to get us to question what we've been doing with schedulers, not a change suggestion per say