This module includes a utility for simplifying the use of promises by making
them behave as synchronous code. It's targeted for Spider Monkey and the latest
versions of V8 (Chrome 29 and upwards) with the --harmony
flag enabled.
Use it by including the gallery-task
module and passing a generator function
to the Y.task
utility:
YUI({
gallery: 'gallery-2013.05.15-21-12'
}).use('json-parse', 'gallery-io-utils', 'gallery-task', function (Y) {
// The function* is the syntax for EcmaScript 6 generators
Y.task(function* () {
var data = yield Y.io.getJSON('/foo');
var result = yield Y.io.postJSON('/bar', {data: data});
Y.log(result.field);
});
});
Y.task is heavily based on Task.js, by David Herman