Hyperlinkv0.8.0-beta.28

SynchronizedRef

SynchronizedRef.updateSomeconsteffect/SynchronizedRef.ts:568
<A>(f: (a: A) => Option.Option<A>): (
  self: SynchronizedRef<A>
) => Effect.Effect<void>
<A>(
  self: SynchronizedRef<A>,
  f: (a: A) => Option.Option<A>
): Effect.Effect<void>

Applies a partial update to the current value. Option.some stores the new value; Option.none leaves the ref unchanged.

When to use

Use to apply a pure conditional SynchronizedRef update without returning a value.

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