On Tue, Feb 4, 2014 at 10:55 AM, Rick Waldron <[email protected]> wrote:
> Per Resolution
> (https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-01/jan-30.md#conclusionresolution-3)
>
> - Promise.cast is renamed to Promise.resolve (remove old Promise.resolve)
> - Keep then, reject chain (NOT DEFER, reject!)
> - Renaming .cast thus removes over-wrapping (always-wrap) deoptimization in
> old Promise.resolve

Okay, so this is discarding the previous consensus, right?  Monadic
promises are thrown out?

This breaks async maps forever, then. :/  With the previous consensus,
the result promise from an async map could be observed directly with
.chain(), and it worked great regardless of what was stored inside the
map.

With only flat promises, if you store a promise in an async map and
then try to retrieve it later, the error callback gets called if the
key wasn't in the map *or* the key was in the map, but the stored
value was a rejected promise.  You have to spread your program logic
over both callbacks to catch that case (or more likely, people will
just write programs that break occasionally because they assumed that
the reject branch of the AM.get() promise is only for failed lookups,
as the documentation probably says).

Similarly, if you store a forever-pending promise in the async map,
it's impossible to ever retrieve it.  Even just a long-pending promise
will stall your program's logic while it waits, preventing you from
updating UI when the map returns and *then* completing the operation
when the stored promise finally resolves.

The only way to get a working async map is to defensively store your
values in a single-element array (or some other non-promise wrapper
object) and unwrap them on retrieval.

Pretending that all promises are identical identity-less wrappers that
can be arbitrarily collapsed is such a mistake. >_<

Le sigh.

~TJ
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to