Comment #46 on issue 3093 by [email protected]: Debugging promises
http://code.google.com/p/v8/issues/detail?id=3093
Any case where you prefetch data often decouples the handling of a
rejection from the time the promise was rejected, since you only
`.then(...)` the promise when you want to use the data.
Any case where you use promises to signal state transitions also often
falls into this pattern. For example a font face may fail to load, or a
stream may fail to close, but you only use their `.loaded` or `.closed`
promises when you actually need to react to those situations, e.g. after
the text you wish to render in that font has been received from the server,
or after the destination you're writing the stream's data to signals that
it is ready to accept more data.
These kind of situations are especially common in UI programming, where you
may be performing some operation asynchronously, but only need to know
about its failure when the user clicks "show me the results" or "next page"
or "print" or similar. Indeed, in those cases there's often nowhere to
sensibly display the error until the user action takes place!
For example, in an eBook reading application, we had promises representing
the next and previous page renderings, which were kicked off ahead of time.
When the user clicked the next page, we would do the page transition
animation, clearing out the displayed page. Only at this point would we
`.then()` the next-page promise, rendering the contents into the display
area on fulfillment, and rendering an error message into the display area
on rejection. This could not have been done earlier, because the display
area was filled with the stuff the user was already reading!
In all cases, you can contort your code to avoid delayed-thening,
essentially by immediate-thening and then storing the results in a
placeholder variable that you later poll the value of. But one of the main
benefits of promises is to be able to represent latent asynchronous results
in this way, without such placeholder variables! You're essentially back in
callback land if you lose that ability.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.