Re: [whatwg/dom] Improving ergonomics of events with Observable (#544)

> @benlesh that misses the case where the signal has already aborted, but I guess that's easy to work around?

@jakearchibald In that case you could either synchronously check the signal prior to subscription, or write a simple adapter around it using the Observable constructor. If you're interested in what what might look like, let me know.

> Note that making the Observable returned by first awaitable is still a footgun

@jhusain is correct here. Because Promises are always eager and Observables will lazily start observation, Observables can have side-effects. Which would mean that calling a "then" directly on an Observable would mean creating side-effects, when in Promise's case it would never do that. It would be very surprising behavior for developers.

> Modify the Promise-returning methods to return Observables which notify only once.

Personally, I like this idea as it already exists in this form in RxJS and I know it works out for most use cases. I still think we should have a more obvious method like `toPromise` as well though, because I really believe we should try to provide interop points where we can. It makes the type more powerful.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/544#issuecomment-352132820

Received on Friday, 15 December 2017 22:59:16 UTC