-
Notifications
You must be signed in to change notification settings - Fork 177
Open
Description
jQuery promises implement Promises/A+ specification, and hence support this part of the spec:
2.2.7.1. #If either onFulfilled or onRejected returns a value x, run the Promise Resolution Procedure
see the documentation here:
https://promisesaplus.com/#point-41
ScriptSharp's IDeferred wrapper for the promise doesn't support returning values from onFulfilled callbacks at all, because Action and Callback are defined as delegates that always return void. Here are JavaScript example scenarios that won't be possible to implement in ScriptSharp because of this problem:
var a = $.Deferred();
a.promise()
.then(function (result1) {
return result1 * 5;
})
.then(function (result2) {
return result2 + " as text";
})
.then(function (result3) {
var b = $.Deferred();
setTimeout(function () {
b.resolve(result3 + " delayed");
}, 100);
return b.promise();
})
.then(function (result4) {
alert(result4); // alerts "25 as text delayed"
});
a.resolve(5);
JSFiddle: http://jsfiddle.net/alexarg/dzzj13h4
Metadata
Metadata
Assignees
Labels
No labels