Hyperlinkv0.8.0-beta.28

TxRef

TxRef.getconsteffect/TxRef.ts:247
<A>(self: TxRef<A>): Effect.Effect<A>

Reads the current value of the TxRef.

When to use

Use to read the current value of a TxRef.

Example (Reading transactional references)

import { Effect, TxRef } from "effect"

const program = Effect.gen(function*() {
  const counter = yield* TxRef.make(42)

  // Read the value within a transaction
  const value = yield* Effect.tx(
    TxRef.get(counter)
  )

  console.log(value) // 42
})
combinators
Source effect/TxRef.ts:2471 lines
export const get = <A>(self: TxRef<A>): Effect.Effect<A> => modify(self, (current) => [current, current])
Referenced by 82 symbols