MCPcopy
hub / github.com/Effect-TS/effect / TRefImpl

Class TRefImpl

packages/effect/src/internal/stm/tRef.ts:27–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26/** @internal */
27export class TRefImpl<in out A> implements TRef.TRef<A>, Pipeable {
28 readonly [TRefTypeId] = tRefVariance
29 /** @internal */
30 todos: Map<TxnId.TxnId, Journal.Todo>
31 /** @internal */
32 versioned: Versioned.Versioned<A>
33 constructor(value: A) {
34 this.versioned = new Versioned.Versioned(value)
35 this.todos = new Map()
36 }
37 modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B> {
38 return core.effect<never, B>((journal) => {
39 const entry = getOrMakeEntry(this, journal)
40 const [retValue, newValue] = f(Entry.unsafeGet(entry) as A)
41 Entry.unsafeSet(entry, newValue)
42 return retValue
43 })
44 }
45 pipe() {
46 return pipeArguments(this, arguments)
47 }
48}
49
50/** @internal */
51export const make = <A>(value: A): STM.STM<TRef.TRef<A>> =>

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…