Chain.Runnable 0.01

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.



Details

Author
Michal Charemza
Current version
0.01
GitHub
michalc/Chain.Runnable
Downloads
1379
Category
Utilities
Tags
Report
GitHub Issues

Releases


Dependencies

  • _self_/_current_:
    • Core/Class.Extras
    • Core/Array

How to use

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()
    }
  ]);
});

Why To Use

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.


Discuss

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