<A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (
self: SynchronizedRef<A>
) => Effect.Effect<void, E, R>
<A, R, E>(
self: SynchronizedRef<A>,
f: (a: A) => Effect.Effect<A, E, R>
): Effect.Effect<void, E, R>Runs an effectful update while holding the ref's semaphore and stores the new value if the effect succeeds.
When to use
Use to run an effectful state transition on a SynchronizedRef when storing
the new value is the only result you need.
export const const updateEffect: {
<A, R, E>(
f: (a: A) => Effect.Effect<A, E, R>
): (
self: SynchronizedRef<A>
) => Effect.Effect<void, E, R>
<A, R, E>(
self: SynchronizedRef<A>,
f: (a: A) => Effect.Effect<A, E, R>
): Effect.Effect<void, E, R>
}
Runs an effectful update while holding the ref's semaphore and stores the new
value if the effect succeeds.
When to use
Use to run an effectful state transition on a SynchronizedRef when storing
the new value is the only result you need.
updateEffect: {
<function (type parameter) A in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>A, function (type parameter) R in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>R, function (type parameter) E in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>E>(f: (a: A) => Effect.Effect<A, E, R>f: (a: Aa: function (type parameter) A in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>A) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>A, function (type parameter) E in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>R>): (self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface SynchronizedRef<in out A>A mutable reference whose update and modify operations are serialized with an
internal semaphore, including effectful transformations.
When to use
Use when shared state may be updated by multiple fibers and each update,
including effectful state transitions, must observe one current value and run
one at a time.
SynchronizedRef<function (type parameter) A in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>A>) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, function (type parameter) E in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(f: (a: A) => Effect.Effect<A, E, R>): (self: SynchronizedRef<A>) => Effect.Effect<void, E, R>R>
<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E>(self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface SynchronizedRef<in out A>A mutable reference whose update and modify operations are serialized with an
internal semaphore, including effectful transformations.
When to use
Use when shared state may be updated by multiple fibers and each update,
including effectful state transitions, must observe one current value and run
one at a time.
SynchronizedRef<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A>, f: (a: A) => Effect.Effect<A, E, R>f: (a: Aa: function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R>
} = import dualdual(
2,
<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E>(self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self: interface SynchronizedRef<in out A>A mutable reference whose update and modify operations are serialized with an
internal semaphore, including effectful transformations.
When to use
Use when shared state may be updated by multiple fibers and each update,
including effectful state transitions, must observe one current value and run
one at a time.
SynchronizedRef<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A>, f: (a: A) => Effect.Effect<A, E, R>f: (a: Aa: function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>A, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R>): import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, function (type parameter) E in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>E, function (type parameter) R in <A, R, E>(self: SynchronizedRef<A>, f: (a: A) => Effect.Effect<A, E, R>): Effect.Effect<void, E, R>R> =>
self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self.SynchronizedRef<in out A>.semaphore: Semaphore.Semaphore(property) SynchronizedRef<in out A>.semaphore: {
resize: (this: Semaphore, permits: number) => Effect.Effect<void>;
withPermits: (this: Semaphore, permits: number) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermit: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
withPermitsIfAvailable: (this: Semaphore, permits: number) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Option.Option<A>, E, R>;
take: (this: Semaphore, permits: number) => Effect.Effect<number>;
release: (this: Semaphore, permits: number) => Effect.Effect<number>;
releaseAll: Effect.Effect<number>;
}
semaphore.withPermit(import EffectEffect.suspend(() => {
const const value: Avalue = const getUnsafe: <A>(
self: SynchronizedRef<A>
) => A
Reads the current value synchronously, bypassing the Effect API and the
ref's semaphore.
When to use
Use when you need immediate synchronous access to a SynchronizedRef value
in low-level code that can safely read outside an Effect.
getUnsafe(self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self)
return import EffectEffect.map(f: (a: A) => Effect.Effect<A, E, R>f(const value: Avalue), (newValue: anynewValue) => {
self: SynchronizedRef<A>(parameter) self: {
backing: Ref.Ref<A>;
semaphore: Semaphore.Semaphore;
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
self.SynchronizedRef<in out A>.backing: Ref.Ref<A>(property) SynchronizedRef<in out A>.backing: {
ref: MutableRef.MutableRef<A>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
backing.ref.current = newValue: anynewValue
})
}))
)