We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1babcaa commit b71a7fcCopy full SHA for b71a7fc
test/createRedux.spec.js
@@ -69,4 +69,29 @@ describe('createRedux', () => {
69
70
expect(state).toEqual(redux.getState().todoStore);
71
});
72
+
73
+ it('should handle nested dispatches gracefully', () => {
74
+ function foo(state = 0, action) {
75
+ return action.type === 'foo' ? 1 : state;
76
+ }
77
78
+ function bar(state = 0, action) {
79
+ return action.type === 'bar' ? 2 : state;
80
81
82
+ redux = createRedux({ foo, bar });
83
84
+ redux.subscribe(() => {
85
+ // What the Connector ends up doing.
86
+ const state = redux.getState();
87
+ if (state.bar === 0) {
88
+ redux.dispatch({type: 'bar'});
89
90
+ });
91
92
+ redux.dispatch({type: 'foo'});
93
94
+ // Either this or throw an error when nesting dispatchers
95
+ expect(redux.getState()).toEqual({foo: 1, bar: 2});
96
97
0 commit comments