CelloCello / syncobj

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

syncobj.js

You can use syncobj.js to let your function synchronous.

Your function should be in this pattern:

// params: {}
// sCB: success callback function
// eCB: error callback function
function foo(params, sCB, eCB) {
	// ...
}

Example

var sync = new SyncObj(doneFunc);
sync.addFunc(testFunc, {str: "aaa"});
sync.addFunc(testFunc, {str: "bbb"});
sync.addFunc(testFunc, {str: "ccc"});
sync.start();

function testFunc(params, sCb) {
  console.log(params.str);
  sCb();
}

function doneFunc() {
  console.log("all done");
}

About


Languages

Language:JavaScript 56.9%Language:HTML 43.1%