refactor(interface): Move resetAll to top level

This commit is contained in:
Kai Moseley 2018-06-13 09:45:28 +01:00
parent 9fe5f3f0b7
commit 5dccc991e0
3 changed files with 8 additions and 10 deletions

View File

@ -148,10 +148,12 @@ const exampleBatchedUpdateHittingSameReducerMultipleTimes = createCombinedAction
``` ```
#### resetAll #### 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 #### Examples

View File

@ -20,7 +20,7 @@ describe("buildStoreChunk", () => {
example: Types.reducer(Types.string()) example: Types.reducer(Types.string())
}) })
) )
).toEqual(["reducers", "actions", "selectors"]); ).toEqual(["reducers", "actions", "selectors", "resetAll"]);
}); });
describe("Resulting chunk", () => { describe("Resulting chunk", () => {
@ -92,8 +92,7 @@ describe("buildStoreChunk", () => {
"nested2", "nested2",
"nested3", "nested3",
"nested4", "nested4",
"nested5", "nested5"
"resetAll"
]); ]);
}); });
it("Actions object has the correct top level structure for a non nested chunk", () => { 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({ expect(chunk.selectors.nested2(store.getState())).toEqual({
foo: 0, foo: 0,
bar: "" bar: ""

View File

@ -105,10 +105,7 @@ export function buildStoreChunk(
if (locationString === name) { if (locationString === name) {
return { return {
...processedStructure, ...processedStructure,
actions: {
...processedStructure.actions,
resetAll: createResetAllAction(name, processedStructure.actions) resetAll: createResetAllAction(name, processedStructure.actions)
}
}; };
} }