- From: Jan-Ivar Bruaroey <notifications@github.com>
- Date: Fri, 30 Jul 2021 11:47:44 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/issues/1153/890085604@github.com>
(This is the subjective part) > For _promises_ the promise guide's [ยง 2. When to use promises](https://www.w3.org/2001/tag/doc/promises-guide#when-to-use) set these criteria, which I believe successfully settled many a debate. For example, among those criteria were NOT: Is using promises less to type than callbacks? Is it simpler(-looking)? Because sometimes, using promises meant _more_ to type and read than with callbacks (especially before `async`/`await` came along). Instead the criteria were distinctly intrinsic to the nature of the operation of the API. They were good. This may seem obvious in hindsight, but adopting promises throughout the platform wholesale as the idiomatic pattern for (most, based on these criteria) async behavior in all new APIs, I think was critical to its success. IOW, the prevalence of the pattern was itself fundamental to its utility/benefit/success, as it enabled [composition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#composition). Going half-in would have been painful to the point of jeopardizing its success (with failure probably blamed on the new pattern). And if people didn't like it, they could work around it with `p.then(successCallback, failureCallback)`. ### What's the corollary to streams? Streams like promises have a learning curve, and (like promises had) a lack of enough established APIs using them to make the synergistic benefits obvious (not enough sources & sinks for critical mass yet). This takes me back to when promises were hard to argue for, because they weren't prevalent. We are seeing this resurface in decisions being contemplated based on what seems "simpler", or based on simple comparisons between code examples (that aren't or cannot use `pipeTo` for instance), instead of asking: is there something a streams API prevent you from doing? This is basically the streams pattern being challenged over and over. I hope there's enough feedback for a guide here. -- 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/streams/issues/1153#issuecomment-890085604
Received on Friday, 30 July 2021 18:47:56 UTC