Hyperlinkv0.8.0-beta.28

SynchronizedRef

SynchronizedRef.updateconsteffect/SynchronizedRef.ts:458
<A>(f: (a: A) => A): (self: SynchronizedRef<A>) => Effect.Effect<void>
<A>(self: SynchronizedRef<A>, f: (a: A) => A): Effect.Effect<void>

Updates the value of the SynchronizedRef with a function, serialized by the ref's semaphore.

When to use

Use to apply a pure state transition to a SynchronizedRef as a serialized Effect.

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