MCPcopy Create free account
hub / github.com/effect-app/libs / drain

Function drain

repos/effect/packages/effect/src/Channel.ts:3000–3019  ·  view source on GitHub ↗
(
  self: Channel<
    OutElem,
    OutErr,
    OutDone,
    InElem,
    InErr,
    InDone,
    Env
  >
)

Source from the content-addressed store, hash-verified

2998 *
2999 * **Example** (Flattening nested channels)
3000 *
3001 * ```ts import.meta.vitest
3002 * import { Channel, Data, Effect } from "effect"
3003 *
3004 * class FlattenError extends Data.TaggedError("FlattenError")<{
3005 * readonly cause: string
3006 * }> {}
3007 *
3008 * // Create a channel that outputs channels
3009 * const nestedChannels = Channel.fromIterable([
3010 * Channel.fromIterable([1, 2]),
3011 * Channel.fromIterable([3, 4]),
3012 * Channel.fromIterable([5, 6])
3013 * ])
3014 *
3015 * // Flatten the nested channels
3016 * const flattenedChannel = Channel.flatten(nestedChannels)
3017 *
3018 * Effect.runSync(Channel.runCollect(flattenedChannel)) // => [1, 2, 3, 4, 5, 6]
3019 * ```
3020 *
3021 * @category constructors
3022 * @since 2.0.0

Callers

nothing calls this directly

Calls 2

transformPullFunction · 0.70
succeedMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…