login/register

Snip!t from collection of Alan Dix

see all channels for Alan Dix

Snip
summary

At their most basic, promises are a bit like event liste...
A promise can only succeed or fail once. It cannot s ...
If a promise has succeeded or failed and you later a ...
This is extremely useful for async success/failure, beca ...

JavaScript Promises: There and back again - HTML5 Rocks
http://www.html5rocks.com/en/tutorials/es6/promises/

Categories

/Channels/techie/JavaScript

[ go to category ]

For Snip

loading snip actions ...

For Page

loading url actions ...

At their most basic, promises are a bit like event listeners except:

  • A promise can only succeed or fail once. It cannot succeed or fail twice, neither can it switch from success to failure or vice versa
  • If a promise has succeeded or failed and you later add a success/failure callback, the correct callback will be called, even though the event took place earlier

This is extremely useful for async success/failure, because you're less interested in the exact time something became available, and more interested in reacting to the outcome.

HTML

<p>At their most basic, promises are a bit like event listeners except:</p> <ul> <li>A promise can only succeed or fail once. It cannot succeed or fail twice, neither can it switch from success to failure or vice versa</li> <li>If a promise has succeeded or failed and you later add a success/failure callback, the correct callback will be called, even though the event took place earlier</li> </ul> <p>This is extremely useful for async success/failure, because you're less interested in the exact time something became available, and more interested in reacting to the outcome.</p>