Skip to content

Commit

Permalink
feat(loadFeatureMiddleware): call features' init with feature id
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Dec 18, 2016
1 parent 9721225 commit 830d6c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/loadFeatureMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function loadFeatureMiddleware<S, A: {type: $Subtype<string>}>(
const priorFeature = (getFeatures(store.getState()) || {})[id]
const result = next(action)
const feature = (getFeatures(store.getState()) || {})[id]
if (!priorFeature && feature && feature.init instanceof Function) feature.init(store)
if (!priorFeature && feature && feature.init instanceof Function) feature.init(store, id)
return result
},
[LOAD_FEATURE]: (store: MiddlewareAPI<S, A | FeatureAction>) => (next: Dispatch<A | FeatureAction>) => (action: any): any => {
Expand Down
1 change: 1 addition & 0 deletions test/loadFeatureMiddlewareTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ describe('loadFeatureMiddleware', () => {
store.dispatch(addFeature('f1', f1))
expect(init.args[0][0].dispatch).to.be.an.instanceOf(Function)
expect(init.args[0][0].getState).to.be.an.instanceOf(Function)
expect(init.args[0][1]).to.equal('f1')
})
it("doesn't call init on features that are already added", () => {
const init = sinon.spy()
Expand Down

0 comments on commit 830d6c2

Please sign in to comment.