@internal
| 109 | |
| 110 | /** @internal */ |
| 111 | class TSubscriptionRefImpl<in out A> implements TSubscriptionRef.TSubscriptionRef<A> { |
| 112 | readonly [TSubscriptionRefTypeId] = TSubscriptionRefVariance |
| 113 | readonly [TRef.TRefTypeId] = tRefVariance |
| 114 | |
| 115 | constructor( |
| 116 | readonly ref: TRef.TRef<A>, |
| 117 | readonly pubsub: TPubSub.TPubSub<A> |
| 118 | ) {} |
| 119 | |
| 120 | get todos() { |
| 121 | return this.ref.todos |
| 122 | } |
| 123 | |
| 124 | get versioned() { |
| 125 | return this.ref.versioned |
| 126 | } |
| 127 | |
| 128 | pipe() { |
| 129 | return pipeArguments(this, arguments) |
| 130 | } |
| 131 | |
| 132 | get changes(): STM.STM<TQueue.TDequeue<A>> { |
| 133 | return STM.gen(this, function*() { |
| 134 | const first = yield* TQueue.unbounded<A>() |
| 135 | yield* TQueue.offer(first, yield* TRef.get(this.ref)) |
| 136 | return new TDequeueMerge(first, yield* TPubSub.subscribe(this.pubsub)) |
| 137 | }) |
| 138 | } |
| 139 | |
| 140 | modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B> { |
| 141 | return pipe( |
| 142 | TRef.get(this.ref), |
| 143 | STM.map(f), |
| 144 | STM.flatMap(([b, a]) => |
| 145 | pipe( |
| 146 | TRef.set(this.ref, a), |
| 147 | STM.as(b), |
| 148 | STM.zipLeft(TPubSub.publish(this.pubsub, a)) |
| 149 | ) |
| 150 | ) |
| 151 | ) |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /** @internal */ |
| 156 | export const make = <A>(value: A): STM.STM<TSubscriptionRef.TSubscriptionRef<A>> => |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…