MCPcopy Create free account
hub / github.com/Effect-TS/effect / setValue

Method setValue

packages/effect/src/unstable/reactivity/AtomRegistry.ts:685–718  ·  view source on GitHub ↗
(value: A)

Source from the content-addressed store, hash-verified

683 }
684
685 setValue(value: A): void {
686 if ((this.state & NodeFlags.initialized) === 0) {
687 this.state = NodeState.valid
688 this._value = value
689
690 if (batchState.phase === BatchPhase.collect) {
691 batchState.notify.add(this)
692 } else {
693 this.notify()
694 }
695
696 return
697 }
698
699 this.state = NodeState.valid
700 if (this.atom.equals(this._value, value)) {
701 return
702 }
703
704 this._value = value
705 if (this.skipInvalidation) {
706 this.skipInvalidation = false
707 } else {
708 this.invalidateChildren()
709 }
710
711 if (this.listeners.size > 0) {
712 if (batchState.phase === BatchPhase.collect) {
713 batchState.notify.add(this)
714 } else {
715 this.notify()
716 }
717 }
718 }
719
720 addParent(parent: NodeImpl<any>): void {
721 this.parents.add(parent)

Callers 6

valueMethod · 0.95
setInitialValueMethod · 0.95
hydrateFunction · 0.45
ensureNodeMethod · 0.45
setSelfFunction · 0.45
setSelfMethod · 0.45

Calls 4

notifyMethod · 0.95
invalidateChildrenMethod · 0.95
equalsMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected