Skip to content

aravindbaskaran/simple-async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-async

A very lightweight javascript library for async iteration. Callback-chain-free. Zero dependency.

Everytime I needed to do async iteration (for e.g. loading content sequentially from web services), ended up writing different versions of same logic to help. So why not put it up for everyone who needs it.

This library is modular and thin, easy-to-integrate with any libraries. And most importantly very simple.

Usage

var a = ["a", "b", "c"];
// You could do a for-loop, but why do that when you can do it async!
new AsyncIterator(
    a, function(iterator){
      // step
      console.log("in step - " + iterator.current() + " - Remaining - " + iterator.remaining());
      iterator.step();
    }, function(iterator){
      // start
      console.log("Starting the iteration");
    }, function(iterator){
      // end
      console.log("Ending the iteration");
    }
).step();

Example

Check out code under examples folder

Dynamic loading images sequentially and showing them on a page

Or jsfiddle!

Result - http://jsfiddle.net/aravindbaskaran/K63vt/embedded/result/

Fiddle - http://jsfiddle.net/aravindbaskaran/K63vt/

Hope it helps in reducing your rewrites for every project!

Licensed under Apache v2

About

A very lightweight javascript library for async iteration. Callback-chain-free. Zero dependency

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published