-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move updateComputed and notifyEffect functions to global scope
- Loading branch information
1 parent
a77698d
commit b1c20bd
Showing
8 changed files
with
102 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,39 @@ | ||
import { Computed, updateComputed } from './computed.js'; | ||
import { Effect, notifyEffect } from './effect.js'; | ||
import { EffectScope } from './effectScope.js'; | ||
import { createSystem, Dependency, Subscriber } from './system.js'; | ||
import { Computed } from './computed.js'; | ||
import { Effect } from './effect.js'; | ||
|
||
export function isComputed(sub: Subscriber & Dependency): sub is Computed { | ||
return 'update' in sub; | ||
return 'getter' in sub; | ||
} | ||
|
||
export function isEffect(sub: Subscriber & Dependency): sub is Effect { | ||
return 'notify' in sub; | ||
export function isEffect(sub: Subscriber): sub is Effect | EffectScope { | ||
return 'run' in sub; | ||
} | ||
|
||
const { | ||
drainQueuedEffects, | ||
endTrack, | ||
isDirty, | ||
link, | ||
propagate, | ||
runInnerEffects, | ||
drainQueuedEffects, | ||
shallowPropagate, | ||
startTrack, | ||
} = createSystem({ | ||
isComputed, | ||
isEffect, | ||
updateComputed(computed) { | ||
return computed.update(); | ||
}, | ||
notifyEffect(effect) { | ||
effect.notify(); | ||
}, | ||
updateComputed, | ||
notifyEffect, | ||
}); | ||
|
||
export { | ||
drainQueuedEffects, | ||
endTrack, | ||
isDirty, | ||
link, | ||
propagate, | ||
runInnerEffects, | ||
drainQueuedEffects, | ||
shallowPropagate, | ||
startTrack, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters