不要怂,就是干,撸起袖子干!

Commit e4a65dff by sdepold

append the results of the emitters as arbitrary params to the callback of the query chainer

1 parent dbc8b30e
......@@ -128,7 +128,7 @@ module.exports = (function() {
var status = (this.fails.length == 0 ? 'success' : 'error')
, result = (this.fails.length == 0 ? this[resultsName] : this.fails)
this.eventEmitter.emit(status, result)
this.eventEmitter.emit.apply(this.eventEmitter, [status, result].concat(result))
}
}
......
......@@ -76,6 +76,25 @@ describe('QueryChainer', function() {
emitter1.run()
emitter3.run()
})
it("returns the result as an array and each result as part of the callback signature", function(done) {
var emitter1 = new CustomEventEmitter(function(e) { e.emit('success', 1) })
, emitter2 = new CustomEventEmitter(function(e) { e.emit('success', 2) })
this.queryChainer.add(emitter1)
this.queryChainer.add(emitter2)
this.queryChainer.run().success(function(results, result1, result2) {
expect(result1).toBeDefined()
expect(result2).toBeDefined()
expect(result1).toEqual(1)
expect(result2).toEqual(2)
done()
})
emitter2.run()
emitter1.run()
})
})
describe('runSerially', function() {
......@@ -120,5 +139,21 @@ describe('QueryChainer', function() {
done()
})
})
it("returns the result as an array and each result as part of the callback signature", function(done) {
var emitter1 = new CustomEventEmitter(function(e) { e.emit('success', 1) })
, emitter2 = new CustomEventEmitter(function(e) { e.emit('success', 2) })
this.queryChainer.add(emitter1, 'run')
this.queryChainer.add(emitter2, 'run')
this.queryChainer.runSerially().success(function(results, result1, result2) {
expect(result1).toBeDefined()
expect(result2).toBeDefined()
expect(result1).toEqual(1)
expect(result2).toEqual(2)
done()
})
})
})
})
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!