File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed
Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -94,9 +94,9 @@ export class Derived {
9494 this . isDirty = false
9595 this . paths = getPaths ( )
9696
97- // We add the paths to the derived
98- this . trackStateTree . pathDependencies . clear ( )
97+ this . trackStateTree . clearTracking ( )
9998
99+ // We add the paths tracked to the derived
100100 for ( let path of this . paths ) {
101101 this . trackStateTree . addTrackingPath ( path )
102102 }
Original file line number Diff line number Diff line change @@ -52,13 +52,7 @@ export class TrackStateTree<T extends object> implements ITrackStateTree<T> {
5252 this . master . changeTrackStateTree ( this )
5353 this . shouldTrack = true
5454
55- if ( this . callback ) {
56- for ( let path of this . pathDependencies ) {
57- this . master . removePathDependency ( path , this . callback )
58- }
59- }
60-
61- this . pathDependencies . clear ( )
55+ this . clearTracking ( )
6256
6357 if ( cb ) {
6458 this . callback = ( ...args ) => {
@@ -71,6 +65,15 @@ export class TrackStateTree<T extends object> implements ITrackStateTree<T> {
7165
7266 return this
7367 }
68+ clearTracking ( ) {
69+ if ( this . callback ) {
70+ for ( let path of this . pathDependencies ) {
71+ this . master . removePathDependency ( path , this . callback )
72+ }
73+ }
74+
75+ this . pathDependencies . clear ( )
76+ }
7477 stopTracking ( ) {
7578 this . shouldTrack = false
7679 }
@@ -92,11 +95,7 @@ export class TrackStateTree<T extends object> implements ITrackStateTree<T> {
9295 return this
9396 }
9497
95- for ( let path of this . pathDependencies ) {
96- this . master . removePathDependency ( path , this . callback )
97- }
98-
99- this . pathDependencies . clear ( )
98+ this . clearTracking ( )
10099 this . callback = null
101100 this . proxifier = this . master . proxifier
102101
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export interface ITrackStateTree<T extends object> {
5959 canTrack ( ) : boolean
6060 canMutate ( ) : boolean
6161 dispose ( ) : ITrackStateTree < T >
62+ clearTracking ( ) : void
6263 master : IProxyStateTree < T >
6364 shouldTrack : boolean
6465 proxifier : IProxifier < T >
You can’t perform that action at this time.
0 commit comments