Skip to content

HTML50/chain.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

chain.js

a tiny lib for executing synchronous and asynchronous functions in order.

Demo

load images and show them with chain.js

Usage

include chain.js and new Chain when document is ready.

<script src='chain.js'></script>
<script>
var job = new Chain(some functions);
job.start();
</script>

Options

Chain.start()

start the job in the task queue.

var job = new Chain(fn1,fn2,fn3);
job.start();

Chain.add(fn)

add a job in the end of task queue.

function fn4(){
  //do something
}

job.add(fn4);
//job list: [fn1,fn2,fn3,fn4]

Chain.add(index, fn)

add a job in specified position.

function fn4(){
  //do something
}

job.add(0,fn4);
//job list: [fn4,fn1,fn2,fn3]

Todolist

  • basic usage
  • optimize setTimeout, ajax in different situation

Contributions

Contributions are welcome. 

Feel free to create issues and pull request.

About

asyn/syn function executed in order

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors