effect-io-ai

Package: effect
Module: SynchronizedRef

SynchronizedRef.getAndUpdate

Updates the current value atomically with a function and returns the previous value, serialized by the ref’s semaphore.

When to use

Use to run a pure SynchronizedRef state update when the previous stored value is also needed.

See

Signature

declare const getAndUpdate: { <A>(f: (a: A) => A): (self: SynchronizedRef<A>) => Effect.Effect<A>; <A>(self: SynchronizedRef<A>, f: (a: A) => A): Effect.Effect<A>; }

Source

Since v2.0.0