lazy-task
v0.0.2
Published
lazy task with removing duplicate items
Downloads
3
Readme
lazy-task
Lazy task with removing duplicate items.
If you are troubled with that huge function call during a interval, and argument are exactly same, and you want this function only called once. Lazy task is what you want.
Install
npm install lazy-task
how to use
lazyTask = require("lazy-task");
lazyTask.set("interval", 1); //set interval by minute
// register task and call back
lazyTask.registerTask("Test", function(obj) {
console.log("Task: Test");
console.log("Dupliate count: " + obj.count);
return console.dir(obj.entity);
});
testEntity = {
message: "hello lazy task"
};
i = 0;
while (i < 10) {
// add content to task
lazyTask.addTaskEntity("Test", testEntity);
i++;
}
So after one minute, you will get following output:
Task: Test
Duplicate count: 10
{ message: 'hello lazy task' }
License
MIT