-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
somehow to pass context #13
Comments
function fn1 (cb) {
assert.equal(this.hello, 'world')
this.foo = 'foo'
cb(null, 1)
}
function fn2 (cb) {
assert.equal(this.foo, 'foo')
assert.equal(this.hello, 'world')
this.bar = 'bar'
cb(null, 2)
}
function fn3 (cb) {
assert.equal(this.bar, 'bar')
assert.equal(this.hello, 'world')
cb(null, 3)
}
var ctx = {hello: 'world'};
var seriesDone = bach.series(fn1.bind(ctx), fn2.bind(ctx), fn3.bind(ctx))
series(function (err, res) {
console.log(res)
//=> [1, 2, 3]
}) It is a little more verbose, but being verbose and explicit never hurt anyone. It also allows you to avoid passing context to some functions if you want. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To the each function? Actually it would be same for all in stack.
like middleware/plugin stack
The text was updated successfully, but these errors were encountered: