effect-io-ai

Package: effect
Module: Channel

Channel.toPullScoped

Converts a channel to a Pull within an existing scope.

Example (Converting channels to scoped pulls)

import { Channel, Data, Effect, Scope } from "effect"

class ScopedPullError extends Data.TaggedError("ScopedPullError")<{
  readonly reason: string
}> {}

// Create a channel
const numbersChannel = Channel.fromIterable([1, 2, 3])

// Convert to Pull with explicit scope
const scopedPullEffect = Effect.gen(function*() {
  const scope = yield* Scope.make()
  const pull = yield* Channel.toPullScoped(numbersChannel, scope)
  return pull
})

Signature

declare const toPullScoped: <OutElem, OutErr, OutDone, Env>(self: Channel<OutElem, OutErr, OutDone, unknown, unknown, unknown, Env>, scope: Scope.Scope) => Effect.Effect<Pull.Pull<OutElem, OutErr, OutDone, Env>, never, Env>

Source

Since v4.0.0