File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/node_modules/proxy-state-tree/src Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -192,8 +192,16 @@ export class ProxyStateTree<T extends object> implements IProxyStateTree<T> {
192192 callback ( changes . mutations , sortedPaths , flushId , isAsync )
193193 }
194194
195- for ( let callback of this . flushCallbacks ) {
196- callback ( changes . mutations , sortedPaths , flushId , isAsync )
195+ // We have to ensure that we iterate all callbacks. One flush might
196+ // lead to a change of the array (disposing), which means something
197+ // might be skipped. But we still want to allow removal of callbacks,
198+ // we just do not want to skip any, which is why we still check if it
199+ // exists in the original array
200+ const flushCallbacks = this . flushCallbacks . slice ( )
201+ for ( let callback of flushCallbacks ) {
202+ if ( this . flushCallbacks . includes ( callback ) ) {
203+ callback ( changes . mutations , sortedPaths , flushId , isAsync )
204+ }
197205 }
198206
199207 paths . clear ( )
You can’t perform that action at this time.
0 commit comments