Hyperlinkv0.8.0-beta.28

Channel

Channel.pipeToconsteffect/Channel.ts:6515
<OutElem2, OutErr2, OutDone2, OutElem, OutErr, OutDone, Env2>(
  that: Channel<
    OutElem2,
    OutErr2,
    OutDone2,
    OutElem,
    OutErr,
    OutDone,
    Env2
  >
): <InElem, InErr, InDone, Env>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
) => Channel<
  OutElem2,
  OutErr2,
  OutDone2,
  InElem,
  InErr,
  InDone,
  Env2 | Env
>
<
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone,
  Env,
  OutElem2,
  OutErr2,
  OutDone2,
  Env2
>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  that: Channel<
    OutElem2,
    OutErr2,
    OutDone2,
    OutElem,
    OutErr,
    OutDone,
    Env2
  >
): Channel<OutElem2, OutErr2, OutDone2, InElem, InErr, InDone, Env2 | Env>

Returns a new channel that pipes the output of this channel into the specified channel. The returned channel has the input type of this channel, and the output type of the specified channel, terminating with the value of the specified channel.

Example (Piping one channel into another)

import { Channel, Data } from "effect"

class PipeError extends Data.TaggedError("PipeError")<{
  readonly stage: string
}> {}

// Create source and transform channels
const sourceChannel = Channel.fromIterable([1, 2, 3])
const transformChannel = Channel.map(sourceChannel, (n: number) => n * 2)

// Pipe the source into the transform
const pipedChannel = Channel.pipeTo(sourceChannel, transformChannel)

// Outputs: 2, 4, 6
sequencing
Source effect/Channel.ts:651520 lines
export const pipeTo: {
  <OutElem2, OutErr2, OutDone2, OutElem, OutErr, OutDone, Env2>(
    that: Channel<OutElem2, OutErr2, OutDone2, OutElem, OutErr, OutDone, Env2>
  ): <InElem, InErr, InDone, Env>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
  ) => Channel<OutElem2, OutErr2, OutDone2, InElem, InErr, InDone, Env2 | Env>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, OutElem2, OutErr2, OutDone2, Env2>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
    that: Channel<OutElem2, OutErr2, OutDone2, OutElem, OutErr, OutDone, Env2>
  ): Channel<OutElem2, OutErr2, OutDone2, InElem, InErr, InDone, Env2 | Env>
} = dual(
  2,
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, OutElem2, OutErr2, OutDone2, Env2>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
    that: Channel<OutElem2, OutErr2, OutDone2, OutElem, OutErr, OutDone, Env2>
  ): Channel<OutElem2, OutErr2, OutDone2, InElem, InErr, InDone, Env2 | Env> =>
    fromTransform((upstream, scope) =>
      Effect.flatMap(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))
    )
)
Referenced by 3 symbols