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

Method update

packages/effect/src/unstable/reactivity/AtomRef.ts:287–299  ·  view source on GitHub ↗
(f: (value: A[K]) => A[K])

Source from the content-addressed store, hash-verified

285 return this
286 }
287 update(f: (value: A[K]) => A[K]): AtomRef<A[K]> {
288 if (Array.isArray(this.parent.value)) {
289 const newArray = this.parent.value.slice()
290 newArray[this._prop as number] = f(this.parent.value[this._prop])
291 this.parent.set(newArray as A)
292 } else {
293 this.parent.set({
294 ...this.parent.value,
295 [this._prop]: f(this.parent.value[this._prop])
296 })
297 }
298 return this
299 }
300}
301
302class CollectionImpl<A> extends ReadonlyRefImpl<Array<AtomRef<A>>> implements Collection<A> {

Callers

nothing calls this directly

Calls 2

setMethod · 0.65
fFunction · 0.50

Tested by

no test coverage detected