On 10/8/2013 12:34 PM, Gregory Szorc wrote:
Also, this JS is invalid because a generator function cannot return a
value through "return." For people learning at home, a working
implementation is:
function add2(a, b) {
return Task.spawn(function () {
let sum = yield a + b;
throw new Task.Result(sum);
});
}
This is true of legacy generators, but we have ES6 generators now where
it is possible to return values. Task.jsm has been updated to support
both styles of generators, so it's probably preferable to just always
use the new generators from now on.
// a and b can be any value or promises or generators
function add2(a, b) {
return Task.spawn(function*() {
return (yield a) + (yield b);
});
}
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform