vigetlabs / microcosm

Flux with actions at center stage. Write optimistic updates, cancel requests, and track changes with ease.
http://code.viget.com/microcosm/
MIT License
487 stars 22 forks source link

[microcosm] Async observables #512

Closed nhunzaker closed 6 years ago

nhunzaker commented 6 years ago

Review notes: It's probably best to view this in split-view

What is it

This commit updates the Observable abstraction in Microcosm such that it is asynchronous.

Updates to observables are queued with a universal scheduler. Until this scheduler "flushes" an observable, updates are buffered within an internal list of updates.

Why

The scheduler dispatches updates as fast as the browser will allow it to, using requestIdleCallback. When requestIdleCallback is not provided, it uses setTimeout.

This means that Microcosm's scheduler does not block the browser. Work might be slow, but the browser never suffers.

nhunzaker commented 6 years ago

Thanks, @zporter !