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

Method subscribe

packages/effect/src/unstable/reactivity/AtomRef.ts:254–267  ·  view source on GitHub ↗
(f: (a: A[K]) => void)

Source from the content-addressed store, hash-verified

252 return this.previous
253 }
254 subscribe(f: (a: A[K]) => void): () => void {
255 let previous = this.value
256 return this.parent.subscribe((a) => {
257 if (!a || !(this._prop in (a as any))) {
258 return
259 }
260 const next = a[this._prop]
261 if (Equal.equals(next, previous)) {
262 return
263 }
264 previous = next
265 f(next)
266 })
267 }
268 map<C>(f: (a: A[K]) => C): ReadonlyRef<C> {
269 return new MapRefImpl(this, f)
270 }

Callers

nothing calls this directly

Calls 3

equalsMethod · 0.80
subscribeMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected