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

It’s likely that we can’t provide APIs which allow Observables to be adapted into Promises without introducing footguns. Observable and Promise have very different semantics around dispatch (for good reasons), which creates impedance mismatches.

Champions believe that there are compelling use cases to adapt Observables to Promises, and developers will likely do this anyway. However there is an argument to be made that making adaptation more arduous increases the likelihood that it will only be used when necessary. For example, removing first() will increase the likelihood that developers don’t cavalierly using adapt to a Promise instead of using obs.take(1).subscribe(...) when the latter is more appropriate.  If we accept this argument, we have the following options:

1. Remove Promise-returning methods from the Observable prototype. 
2. Modify the Promise-returning methods to return Observables which notify only once. 

Personally I favor the second. Developers are already used to the idea of subscriptions which notify once (ie { once: true }). However I think there are valid arguments to be made that developers might be confused why functions that return scalars values on Array return a vector type on an Observable. This concern has been expressed when the option was raised in the past. 

@jakearchibald Note that making the Observable returned by first awaitable is still a footgun, because scheduling will still happen on await.


-- 
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-352058175

Received on Friday, 15 December 2017 17:04:40 UTC