Some big-picture questions to help learning about Ember's Promise:
Is Ember's RSVP the same as Tildeio's RSVP? If not, how are they different? How are they related?
Does JavaScript "Promise" come in different flavors, i.e. specifications? If it does, is it true that jQuery Promise uses one set type of Promise specification (what is it?) and Ember's RSVP.Promise uses a different set of Promise specification, namely Promises/A+?
How are Ember RSVP's Promise.then()
, Tildeio RSVP's Promise.then()
, and jQuery's deferred.then()
related? How are Ember's Promise
and then()
different from jQuery's Promise
and then()
? It's good to know to avoid mistakes.
Example of Ember's RSVP.Promise being used in Ember's RESTAdapter's updateRecord's ajax call. These are some SO posts about jQuery Promise, then() #1 and then() #2. I'm in a state of confusion right now.
This is a big topic. We spent a few hours talking about it at last months EmberNYC meetup. If you want to understand promises, a great place to start would be checking out:
- Is Ember's RSVP the same as Tildeio's RSVP? If not, how are they different? How are they related?
Basically the same. Tildeio's RSVP is where active development of RSVP can be found. Ember's RSVP is a copy of that library.
- Does JavaScript "Promise" come in different flavors, i.e. specifications? If it does, is it true that jQuery Promise uses one set type of Promise specification (what is it?) and Ember's RSVP.Promise uses a different set of Promise specification, namely Promises/A+?
For sure it comes in different flavors, not so much by design but it's how things evolved. Promises/A+ is one of many proposed promise specs and seems to have the most traction. Most promises implementations (including RSVP) are compliant with Promises/A+, meaning that they pass the test-suite.
I don't believe jQuery's Promise implementation has a different spec per-se. It is almost-but-not-quite compliant with Promises/A. For the most part they play nice together. There are a couple of edge cases related to error handling where jQuery promises might not behave as you'd expect. Domenic gets into this in detail in his talk, you can also find info about it in this post: whats so great about js promises
How are Ember RSVP's Promise.then(), Tildeio RSVP's Promise.then(), and jQuery's deferred.then() related?
Ember and Tildeio RSVP are the same thing. jQuery's is mostly the same except that:
"If an error handler returns something other than a promise, most implementations consider the error handled, and don’t propagate it. However, jQuery does not consider the error handled in these cases, and propagates it forward anyway." - whats so great about js promises
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With