Hyperlinkv0.8.0-beta.28

Channel

Channel.drainconsteffect/Channel.ts:3000
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
): Channel<never, OutErr, OutDone, InElem, InErr, InDone, Env>

Creates a new channel that consumes all output from the source channel but emits nothing, preserving only the completion value.

Example (Draining channel output)

import { Channel } from "effect"

// Create a channel that outputs values
const sourceChannel = Channel.fromIterable([1, 2, 3, 4, 5])

// Drain all output, keeping only the completion
const drainedChannel = Channel.drain(sourceChannel)

// The channel completes but emits no values
// Useful for consuming side effects without collecting output
constructors
Source effect/Channel.ts:300020 lines
export const drain = <
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone,
  Env
>(
  self: Channel<
    OutElem,
    OutErr,
    OutDone,
    InElem,
    InErr,
    InDone,
    Env
  >
): Channel<never, OutErr, OutDone, InElem, InErr, InDone, Env> =>
  transformPull(self, (pull) => Effect.succeed(Effect.forever(pull, { disableYield: true })))
Referenced by 1 symbols