effect-io-ai

Package: effect
Module: TxDeferred

TxDeferred.make

Creates a new empty TxDeferred.

When to use

Use to create a transactional deferred that can be completed exactly once.

Example (Creating a transactional deferred)

import { Effect, Option, TxDeferred } from "effect"

const program = Effect.gen(function*() {
  const deferred = yield* TxDeferred.make<string, Error>()
  const state = yield* TxDeferred.poll(deferred)
  console.log(Option.isNone(state)) // true
})

Signature

declare const make: <A, E = never>() => Effect.Effect<TxDeferred<A, E>>

Source

Since v2.0.0