-
-
Save chapel/311c246c52708ecf8324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var floc = require('./floc'); | |
function doAsync(value, cb) { | |
setTimeout(function() { | |
cb(null, value / 2); | |
}, 1000); | |
} | |
var callback = floc(function (err, value) { | |
this.valueMain = value; | |
this.one(null, value); | |
}) | |
.add('one', function(err, value) { | |
this.valueOne = value; | |
this.two(null, value * 2); | |
}) | |
.add('two', function (err, value) { | |
this.valueTwo = value; | |
doAsync(value, this.three); | |
}) | |
.add('three', function (err, value) { | |
this.valueThree = value; | |
console.log(this) | |
}) | |
.set('foo2', 'bar2') | |
callback(null, 10); | |
callback(null, 20); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function doAsync(value, cb) { | |
setTimeout(function() { | |
cb(null, value / 2); | |
}, 1000); | |
} | |
function callback(err, value) { | |
var self = {}; | |
self.foo2 = 'bar2'; | |
self.valueMain = value; | |
one(null, value); | |
function one(err, value) { | |
self.valueOne = value; | |
two(null, value * 2); | |
} | |
function two(err, value) { | |
self.valueTwo = value; | |
doAsync(value, this.three); | |
} | |
function three(err, value) { | |
self.valueThree = value; | |
console.log(this); | |
} | |
} | |
callback(null, 10); | |
callback(null, 20); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment