Steven Olmsted![]()
Adds a progress event to Y.Async to easily track the progress of a run.
If you haven't seen gallery-async, start there: http://yuilibrary.com/gallery/show/Async
Once plugged, Y.Async will fire progress events. The eventFacade will contain the properties completed and total.
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2012.06.20-20-07'
}).use('gallery-async-progress', 'node', function(Y) {
var progressNode = Y.one('#progress'),
// This is a dummy function that represents something happening.
unitOfWork = function (success) {
Y.later(Math.random() * 500 + 500, null, success);
};
Y.Async.runQueue(unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork, unitOfWork).plug(Y.Plugin.AsyncProgress).on('progress', function (eventFacade) {
progressNode.set('text', Math.floor(eventFacade.completed / eventFacade.total * 100) + '% Complete');
});
});
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info