File tree 2 files changed +23
-7
lines changed
2 files changed +23
-7
lines changed Original file line number Diff line number Diff line change @@ -128,14 +128,15 @@ class Reactor {
128
128
129
129
if ( this . __batchDepth > 0 ) {
130
130
this . __batchDispatchCount ++
131
- } else if ( this . state !== prevState ) {
132
- try {
133
- this . __notify ( )
134
- } catch ( e ) {
135
- this . __isDispatching = false
136
- throw e
131
+ } else {
132
+ if ( this . state !== prevState ) {
133
+ try {
134
+ this . __notify ( )
135
+ } catch ( e ) {
136
+ this . __isDispatching = false
137
+ throw e
138
+ }
137
139
}
138
-
139
140
this . __isDispatching = false
140
141
}
141
142
}
Original file line number Diff line number Diff line change @@ -209,6 +209,13 @@ describe('Reactor', () => {
209
209
210
210
expect ( ( ) => reactor . dispatch ( 'setTax' , 5 ) ) . not . toThrow ( )
211
211
} )
212
+
213
+ it ( 'should allow subsequent dispatches if a dispatched action doesnt cause state change' , ( ) => {
214
+ reactor . dispatch ( 'noop' )
215
+
216
+ expect ( ( ) => reactor . dispatch ( 'setTax' , 5 ) ) . not . toThrow ( )
217
+ } )
218
+
212
219
it ( 'should allow subsequent dispatches if an observer throws an error' , ( ) => {
213
220
var unWatchFn = reactor . observe ( [ ] , state => {
214
221
throw new Error ( 'observer error' )
@@ -1109,6 +1116,14 @@ describe('Reactor', () => {
1109
1116
} ) . not . toThrow ( )
1110
1117
} )
1111
1118
1119
+ it ( 'should allow subsequent dispatches if batched action doesnt cause state change' , ( ) => {
1120
+ reactor . batch ( ( ) => {
1121
+ reactor . dispatch ( 'noop' )
1122
+ } )
1123
+
1124
+ expect ( ( ) => reactor . dispatch ( 'add' , 'one' ) ) . not . toThrow ( )
1125
+ } )
1126
+
1112
1127
it ( 'should allow subsequent dispatches if an error is raised in an observer' , ( ) => {
1113
1128
var unWatchFn = reactor . observe ( [ ] , state => {
1114
1129
throw new Error ( 'observe error' )
You can’t perform that action at this time.
0 commit comments