Hyperlinkv0.8.0-beta.28

Channel

Channel.onEndconsteffect/Channel.ts:7086
<A, E, R>(onEnd: Effect.Effect<A, E, R>): <
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone,
  Env
>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
) => Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E, R>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  onEnd: Effect.Effect<A, E, R>
): Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>

Runs an effect when the channel completes successfully.

Details

The effect runs before the original done value is propagated. The effect is not run when the channel fails. If the effect fails, the returned channel fails with that error.

hooks
Source effect/Channel.ts:708619 lines
export const onEnd: {
  <A, E, R>(
    onEnd: Effect.Effect<A, E, R>
  ): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
  ) => Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E, R>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
    onEnd: Effect.Effect<A, E, R>
  ): Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Env | R>
} = dual(2, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E, R>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  onEnd: Effect.Effect<A, E, R>
): Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Env | R> =>
  transformPull(self, (pull) =>
    Effect.succeed(Pull.catchDone(
      pull,
      (leftover) => Effect.flatMap(onEnd, () => Cause.done(leftover as OutDone))
    ))))
Referenced by 1 symbols