The Gallery is deprecated. No new Gallery components may be submitted, and modifying existing components is disabled. For more information please read the Gallery Deprecation blog post. This is a static snapshot of the Gallery for archive purposes.
See 3 more by this user. Created: 08/15/11
Last CDN Push: 10/17/12
Build Tag: gallery-2012.10.17-20-00
Project: YUI 3
License: YUI BSD
YUI Version: 3.9.1
Free for use.
This module includes:
<script src="http://yui.yahooapis.com/3.9.1/build/yui/yui-min.js"></script>
YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.10.17-20-00'
}).use('io', 'gallery-deferred', function(Y) {
// make multiple IO requests and deal with them when they are all completed
Y.when(Y.io.get('foo.html'), Y.io.getJSON('bar.json')).then(function (a, b) {
// a and b are arrays with the arguments received by deferred.resolve() in each case,
// so the first element in each array is an EventFacade with responseText and data properties
console.log(a[0].responseText, b[0].data);
});
// use a plugin for chaining asynchronous Node methods one after the other and not all at the same time
var node = Y.one('#foo').plug(Y.Plugin.NodeDeferred);
node.deferred.transition({ left: '300px' })
.transition({ top: '300px' })
.load('some-content.html')
.transition({ width: '420px', height: '420px', top: '30px' });
// create your own deferred functions...
Y.wait = function (ms) {
var deferred = new Y.Deferred();
Y.later(ms, deferred, deferred.resolve);
return deferred.promise();
};
Y.wait(2000).then(function () {
// do something 2 seconds later
});
// ... and add them to all Promises for extra fun!
Y.Promise.prototype.wait = function () {
return this.then(Y.wait);
};
Y.io.postForm('foo.php', '#someform').wait(1000).then(function () {
// do something 1 second later of a certain IO request being completed
// maybe hide a process indicator?
});
});
Subject | Author | Date |
---|---|---|
Change Log | Juan Ignacio Dopazo | 05/28/12 |
Can haz just promises? | Luke Smith | 08/27/12 |
Re: Can haz just promises? | Juan Ignacio Dopazo | 08/28/12 |
deferred Java API and feedback | Sebastián Gurin | 08/30/12 |
What is the best way to start with Promises? | Marco Asbreuk | 02/1/13 |
Re: What is the best way to start with Promises? | Alberto Santini | 02/15/13 |
Re: What is the best way to start with Promises? | Marco Asbreuk | 02/15/13 |
All code on this site is licensed under the BSD License unless stated otherwise.