Skip to content

Commit

Permalink
FinalStore emits a change with the payload
Browse files Browse the repository at this point in the history
  • Loading branch information
goatslacker committed Apr 10, 2015
1 parent e97d5dc commit b8480ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/final-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ export default {
assert(store3.getState().value === 3, 'store3 value correct')

assert.ok(finalStoreListener.calledAfter(store2Listener), 'final store was last one to be called')

const stateListen = sinon.spy()
FinalStore.listen(stateListen)

action.set(27)

assert.ok(stateListen.calledOnce, 'final store called once')
assert(stateListen.args[0][0].payload.data === 27, 'the payload was received')
},
}
}
4 changes: 2 additions & 2 deletions utils/makeFinalStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
module.exports = makeFinalStore

function FinalStore() {
this.dispatcher.register(function () {
this.dispatcher.register(function (payload) {
var stores = Object.keys(this.alt.stores).reduce(function (arr, store) {
return arr.push(this.alt.stores[store].dispatchToken), arr
}.bind(this), [])

this.waitFor(stores)
this.getInstance().emitChange()
this.setState({ payload: payload })
}.bind(this))
}

Expand Down

0 comments on commit b8480ba

Please sign in to comment.