Hyperlinkv0.8.0-beta.28

Ref

Ref.makeconsteffect/Ref.ts:186
<A>(value: A): Effect.Effect<Ref<A>>

Creates a new Ref with the specified initial value.

When to use

Use to create a Ref for shared mutable state inside an Effect program.

Example (Creating a ref)

import { Effect, Ref } from "effect"

const program = Effect.gen(function*() {
  const ref = yield* Ref.make(42)
  const value = yield* Ref.get(ref)
  console.log(value) // 42
})
constructorsmakeUnsafe
Source effect/Ref.ts:1861 lines
export const make = <A>(value: A): Effect.Effect<Ref<A>> => Effect.sync(() => makeUnsafe(value))
Referenced by 8 symbols