Chain.Runnable adds a "run" method to Chain. This method behaves like Chain::chain except that it also calls callChain if and only if the chain is not already running. This can be used in complex cases to maintain a robust chain.
For example, a page may have many clickable components, where a click on each is designed to execute a chain that should not be executed concurrently with other actions.
Use just as Chain::chain, but no need to subsequently call callChain to get the chain going.
Often this will be in response to the user clicking on an element
var myChain = new Chain.Runnable(); someElement.addEvent('click', function() { myChain.run([ function() { // Do something, that when finished calls myChain.callChain() }, function() { // Do something else, that when finished calls myChain.callChain() } ]); });
This class takes care of "remembering" if the chain is running, and so is a quick & easy way of keeping chains that run in response to user action robust.
A note on comments here: These comments are moderated. No comments will show up until they are approved. Comments that are not productive (i.e. inflammatory, rude, etc) will not be approved.
Found a bug in this plugin? Please report it this repository's Github Issues.
blog comments powered by Disqus