effect-io-ai

Package: effect
Module: Ref

Ref.make

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
})

See

Signature

declare const make: <A>(value: A) => Effect.Effect<Ref<A>>

Source

Since v2.0.0