Comment

Comment by littlecranky67

I'd rather have a clear separation of data structures and implemenations:

Promise, Future, Observable = data structures

Bluebird, Fluture, RxJS Observable = implementation of the data structures

Operators (map/race/all) = helper implementations for operating the data structure implementations

Now, different implementations may make different choices, like there are dozens of Promise implementations tuned for either feature richness, speed, or small file size. Same holds true for observables, there are feature-rich libs like RxJS, but also fast and/or small implementations (Bacon, most.js, xstream).

My point: A cancelable promise is basically an observable that emits a single item (and caches that item). So an observable is kind of like a superset of a cancelable promise (and of course a non-cancelable promise). All operator implementations manipulating observables can directly be reused for cancelable and non cancelable promises-like observables; the other way around does NOT hold true.

My main point: Just use observables, they can do everything that promises and cancelable promises can do and, if needed, a lot more. So instead of layering, learn to use this one data structure and you will be able to cope with a lot of async troubles.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton