diff --git a/readme.md b/readme.md index 14464c8..7b4cdb5 100644 --- a/readme.md +++ b/readme.md @@ -148,10 +148,12 @@ const exampleBatchedUpdateHittingSameReducerMultipleTimes = createCombinedAction ``` #### resetAll -The special `resetAll` action is available for nested reducers (i.e. those where more than just one reducer has been defined in the chunk). Calling this action allows you to reset all of the reducers in the chunk simultaneously. +The special `resetAll` action is available for nested reducers (i.e. those where more than just one reducer has been defined in the chunk). Calling this action allows you to reset all of the reducers in the chunk simultaneously. It is exposed at the top level, rather +than within the actions object, due to it being a breaking change when mapping over the actions object. In v2 it will be moved into the +actions object! ``` -store.dispatch(actions.resetAll()); +store.dispatch(storeChunk.resetAll()); ``` #### Examples diff --git a/src/__tests__/buildStoreChunk.test.js b/src/__tests__/buildStoreChunk.test.js index b5874ca..4e7e474 100644 --- a/src/__tests__/buildStoreChunk.test.js +++ b/src/__tests__/buildStoreChunk.test.js @@ -20,7 +20,7 @@ describe("buildStoreChunk", () => { example: Types.reducer(Types.string()) }) ) - ).toEqual(["reducers", "actions", "selectors"]); + ).toEqual(["reducers", "actions", "selectors", "resetAll"]); }); describe("Resulting chunk", () => { @@ -92,8 +92,7 @@ describe("buildStoreChunk", () => { "nested2", "nested3", "nested4", - "nested5", - "resetAll" + "nested5" ]); }); it("Actions object has the correct top level structure for a non nested chunk", () => { @@ -219,7 +218,7 @@ describe("buildStoreChunk", () => { }) ); - store.dispatch(chunk.actions.resetAll()); + store.dispatch(chunk.resetAll()); expect(chunk.selectors.nested2(store.getState())).toEqual({ foo: 0, bar: "" diff --git a/src/buildStoreChunk.js b/src/buildStoreChunk.js index 4cba420..671db6a 100644 --- a/src/buildStoreChunk.js +++ b/src/buildStoreChunk.js @@ -105,10 +105,7 @@ export function buildStoreChunk( if (locationString === name) { return { ...processedStructure, - actions: { - ...processedStructure.actions, - resetAll: createResetAllAction(name, processedStructure.actions) - } + resetAll: createResetAllAction(name, processedStructure.actions) }; }