Can jQuery promises be chained with Ember.RSVP.Promise's?
I need help to understand some promises logic. Here is what I want to
achieve - with jQuery I make get request, then I chain it with my promise
which makes some checks, my code:
http://jsbin.com/UVEpurU/1/edit
function checkInfoPromise(r) {
var ok = true,
promise = Ember.RSVP.Promise(function(resolve, reject) {
if(ok) {
return resolve(r);
}
else {
return reject(r);
}
});
return promise;
}
var requestPromise = $.get('/')
.then(function(r){
return checkInfoPromise(r);
});
requestPromise.then(function(r) {
console.log(r);
}).fail(function(r) {
console.log('fail');
});
and it doesn't work as I expect. Documentation says they should work fine
with each other, but they don't or my code is incorrect.
Same logic with jQuery+jQuery works fine:
http://jsbin.com/AYeyaxO/1/edit
And Ember+Ember works:
http://jsbin.com/iMUgiDo/1/edit
No comments:
Post a Comment