File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/node_modules/proxy-state-tree/src Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -54,21 +54,25 @@ class ProxyStateTree {
5454 }
5555 }
5656 flush ( ) {
57+ const paths = new Set ( )
5758 const pathCallbacksToCall = new Set ( )
5859 const mutations = this . mutations . slice ( )
5960 const flushId = this . currentFlushId ++
6061
6162 for ( let objectChange of this . objectChanges ) {
6263 if ( this . pathDependencies [ objectChange ] ) {
63- for ( let callback of this . pathDependencies [ objectChange ] ) {
64- pathCallbacksToCall . add ( callback )
65- }
64+ paths . add ( objectChange )
6665 }
6766 }
6867
6968 for ( let mutation in this . mutations ) {
70- const path = this . mutations [ mutation ] . path
69+ paths . add ( this . mutations [ mutation ] . path )
70+ }
71+
72+ // Sort so that parent paths are called first
73+ const sortedPaths = Array . from ( paths ) . sort ( )
7174
75+ for ( let path of sortedPaths ) {
7276 if ( this . pathDependencies [ path ] ) {
7377 for ( let callback of this . pathDependencies [ path ] ) {
7478 pathCallbacksToCall . add ( callback )
@@ -80,6 +84,7 @@ class ProxyStateTree {
8084 callback ( flushId )
8185 }
8286
87+ paths . clear ( )
8388 pathCallbacksToCall . clear ( )
8489 this . mutations . length = 0
8590 this . objectChanges . clear ( )
You can’t perform that action at this time.
0 commit comments