Comparing version 0.0.6 to 0.0.7
@@ -36,7 +36,8 @@ var async = require("async"); | ||
//Run any trigger functions now state is set | ||
async.each(transition.triggers||[], function(t, cb){ | ||
return t(obj, cb); | ||
}, function(err) { | ||
return callback(err, obj); | ||
(transition.triggers||[]).forEach(function(t) { | ||
process.nextTick(function() { | ||
return t(obj); | ||
}); | ||
}); | ||
return callback(null, obj); | ||
}); | ||
@@ -43,0 +44,0 @@ |
{ | ||
"name": "reflow", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Simple to use workflow/transitions helper.", | ||
@@ -5,0 +5,0 @@ "keywords" : ["workflow", "workflows"], |
@@ -9,2 +9,15 @@ var assert = require('assert'); | ||
function waitFor(attr, value, callback) { | ||
function wait() { | ||
if(!testBucket.hasOwnProperty(attr)) { | ||
setTimeout(wait, 200); | ||
} else { | ||
assert.equal(testBucket[attr], value); | ||
callback(null); | ||
} | ||
} | ||
wait(); | ||
} | ||
var workflow = { | ||
@@ -41,10 +54,8 @@ one : { | ||
function oneToTwoTrigger1(obj, cb) { | ||
function oneToTwoTrigger1(obj) { | ||
testBucket.oneToTwoTrigger1 = true; | ||
cb(null); | ||
} | ||
function oneToTwoTrigger2(obj, cb) { | ||
function oneToTwoTrigger2(obj) { | ||
testBucket.oneToTwoTrigger2 = true; | ||
cb(null); | ||
} | ||
@@ -57,5 +68,4 @@ | ||
function failTrigger(obj, cb) { | ||
function failTrigger(obj) { | ||
testBucket.failTrigger = true; | ||
cb({badThings:'happened'}); | ||
} | ||
@@ -87,6 +97,8 @@ | ||
assert.equal(testBucket.oneToTwoCond2, true); | ||
assert.equal(testBucket.oneToTwoTrigger1, true); | ||
assert.equal(testBucket.oneToTwoTrigger2, true); | ||
assert.equal(obj.state, 'two'); | ||
done(); | ||
waitFor('oneToTwoTrigger1', true, function() { | ||
waitFor('oneToTwoTrigger2', true, function() { | ||
assert.equal(obj.state, 'two'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -97,3 +109,2 @@ }); | ||
transition(obj, 'three', function(err){ | ||
assert.equal(testBucket.failTrigger, true); | ||
assert.equal(obj.state, 'three'); | ||
@@ -100,0 +111,0 @@ done(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8906
139