Hyperlinkv0.8.0-beta.28

SubscriptionRef

SubscriptionRef.getUnsafeconsteffect/SubscriptionRef.ts:192
<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)
})
getters
export const getUnsafe = <A>(self: SubscriptionRef<A>): A => self.value