<A>(self: SubscriptionRef<A>): ARetrieves the current value of the SubscriptionRef unsafely.
When to use
Use when you are in synchronous internals or test setup where concurrent updates are controlled.
Gotchas
This function directly accesses the underlying reference without any synchronization. It should only be used when you are certain there are no concurrent modifications.
Example (Reading the current value unsafely)
import { Effect, SubscriptionRef } from "effect"
const program = Effect.gen(function*() {
const ref = yield* SubscriptionRef.make(42)
const value = SubscriptionRef.getUnsafe(ref)
console.log(value)
})export const const getUnsafe: <A>(
self: SubscriptionRef<A>
) => A
Retrieves the current value of the SubscriptionRef unsafely.
When to use
Use when you are in synchronous internals or test setup where concurrent
updates are controlled.
Gotchas
This function directly accesses the underlying reference without any
synchronization. It should only be used when you are certain there are no
concurrent modifications.
Example (Reading the current value unsafely)
import { Effect, SubscriptionRef } from "effect"
const program = Effect.gen(function*() {
const ref = yield* SubscriptionRef.make(42)
const value = SubscriptionRef.getUnsafe(ref)
console.log(value)
})
getUnsafe = <function (type parameter) A in <A>(self: SubscriptionRef<A>): AA>(self: SubscriptionRef<A>(parameter) self: {
value: A;
semaphore: Semaphore.Semaphore;
pubsub: PubSub.PubSub<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 SubscriptionRef<in out A>A mutable reference whose updates are serialized and published to
subscribers.
When to use
Use to observe the current value and subsequent updates as a
stream.
The SubscriptionRef namespace containing type definitions associated with
subscription references.
SubscriptionRef<function (type parameter) A in <A>(self: SubscriptionRef<A>): AA>): function (type parameter) A in <A>(self: SubscriptionRef<A>): AA => self: SubscriptionRef<A>(parameter) self: {
value: A;
semaphore: Semaphore.Semaphore;
pubsub: PubSub.PubSub<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.SubscriptionRef<A>.value: Avalue