Hyperlinkv0.8.0-beta.28

SynchronizedRef

SynchronizedRef.setconsteffect/SynchronizedRef.ts:410
<A>(value: A): (self: SynchronizedRef<A>) => Effect.Effect<void>
<A>(self: SynchronizedRef<A>, value: A): Effect.Effect<void>

Sets the value of the SynchronizedRef, serialized by the ref's semaphore.

When to use

Use to replace the current value of a SynchronizedRef with a known value while keeping the write serialized with other synchronized updates.

export const set: {
  <A>(value: A): (self: SynchronizedRef<A>) => Effect.Effect<void>
  <A>(self: SynchronizedRef<A>, value: A): Effect.Effect<void>
} = dual(
  2,
  <A>(self: SynchronizedRef<A>, value: A): Effect.Effect<void> =>
    self.semaphore.withPermit(Ref.set(self.backing, value))
)