effect-io-ai

Package: effect
Module: TxSubscriptionRef

TxSubscriptionRef.changesStream

Returns a Stream of all changes to the TxSubscriptionRef, starting with the current value followed by every subsequent update.

When to use

Use to consume TxSubscriptionRef committed changes as a Stream.

Example (Streaming changes)

import { Effect, Stream, TxSubscriptionRef } from "effect"

const program = Effect.gen(function*() {
  const ref = yield* TxSubscriptionRef.make(0)
  yield* TxSubscriptionRef.set(ref, 1)
  yield* TxSubscriptionRef.set(ref, 2)

  const values = yield* Stream.runCollect(
    TxSubscriptionRef.changesStream(ref).pipe(Stream.take(1))
  )
  console.log(values) // [2]
})

See

Signature

declare const changesStream: <A>(self: TxSubscriptionRef<A>) => Stream.Stream<A, never, never>

Source

Since v3.10.0