riverjs-event-sequence
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -6,4 +6,6 @@ function parallel(){ | ||
parallel.prototype.push = function(){ | ||
arguments[0].args = Array.prototype.slice.call(arguments,1); | ||
this._push(arguments[0]); | ||
var task = arguments[0]; | ||
var args = Array.prototype.slice.call(arguments,1); | ||
this._push(task); | ||
task.apply(this,args); | ||
} | ||
@@ -13,15 +15,6 @@ parallel.prototype._push = Array.prototype.push; | ||
parallel.prototype.forEach = Array.prototype.forEach; | ||
parallel.prototype.update = update; | ||
parallel.prototype.exec = exec; | ||
parallel.prototype.end = update; | ||
parallel.prototype.on = on; | ||
parallel.prototype.emmit = emmit; | ||
function exec(){ | ||
var args = arguments; | ||
var me = this; | ||
this.forEach(function(task,index){ | ||
task.apply(me,task.args || args); | ||
}); | ||
} | ||
function update(){ | ||
@@ -50,3 +43,3 @@ var me = this; | ||
this.listeners[id].forEach(function(listener,index){ | ||
listeners.apply(me,args); | ||
listener.apply(me,args); | ||
}); | ||
@@ -53,0 +46,0 @@ } |
{ | ||
"name": "riverjs-event-sequence", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "a tool for handling serial and parallel asynchronous event quene.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,10 +64,10 @@ riverjs-event-sequence | ||
queue.push(task3,{a:1}); | ||
queue.exec(); | ||
queue.on('end',function(){ | ||
//when all parallel tasks end , here will be triggerd | ||
//all parallel tasks end. | ||
}) | ||
//each task should call this.update , when finished. | ||
//each task should call this.end() , when finished. | ||
//For example: | ||
@@ -78,3 +78,3 @@ | ||
setTimeout(function(){ | ||
me.update(); | ||
me.end(); | ||
},500); | ||
@@ -81,0 +81,0 @@ } |
@@ -11,3 +11,3 @@ var parallel = require('../').parallel; | ||
data.push({name:name,time:Date.now() - beginTime}); | ||
queue.update(); | ||
queue.end(); | ||
}, 50); | ||
@@ -20,3 +20,3 @@ }; | ||
data.push({name:'task2',time:Date.now() - beginTime}); | ||
queue.update(); | ||
queue.end(); | ||
}, 50); | ||
@@ -29,3 +29,3 @@ }; | ||
data.push({name:'task3',time:Date.now() - beginTime}); | ||
queue.update(); | ||
queue.end(); | ||
done(); | ||
@@ -38,3 +38,2 @@ }, 100); | ||
q.push(task3); | ||
q.exec(); | ||
}); | ||
@@ -41,0 +40,0 @@ |
7517
165