Skip to content

Discussing the future of schedulers #2935

Description

@benlesh

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

  1. 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?
  1. It's a large and complicated part of the library
  2. It's a little-understood part of the library
  3. Scheduler arguments aren't symmetric with proposed Observable APIs, like Observable.of
  4. Still doesn't make it much easier to test things like animationFrame or the like.
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions