Skip to content

Commit

Permalink
Merge 941f560 into 4839559
Browse files Browse the repository at this point in the history
  • Loading branch information
finnp committed Sep 13, 2016
2 parents 4839559 + 941f560 commit f0ddc2e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function dispatcher (hooks) {
const send = createSend('subscription: ' + (ns ? ns + ':' + key : key))
cb = wrapHook(cb, subscriptionWraps)
cb(send, function (err) {
applyHook(onErrorHooks, err)
applyHook(onErrorHooks, err, _state, createSend)
})
return cb
})
Expand Down
9 changes: 7 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,17 @@ tape('handlers: subscriptions', (t) => {
})

t.test('should be able to emit an error', (t) => {
t.plan(2)
t.plan(4)
const store = barracks({
onError: (err) => t.equal(err.message, 'oh no!', 'err was received')
onError: (err, state, createSend) => {
t.equal(err.message, 'oh no!', 'err was received')
t.equal((state || {}).a, 1, 'state was passed')
t.equal(typeof createSend, 'function', 'createSend is a function')
}
})

store.model({
state: { a: 1 },
subscriptions: {
mySub: (send, done) => {
t.pass('sub initiated')
Expand Down

0 comments on commit f0ddc2e

Please sign in to comment.