Hyperlinkv0.8.0-beta.28

Channel

Channel.updateContextconsteffect/Channel.ts:7343
<Env, R2>(f: (context: Context.Context<R2>) => Context.Context<Env>): <
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone
>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2>
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, R2>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
  f: (context: Context.Context<R2>) => Context.Context<Env>
): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2>

Transforms the current context before running the channel.

Details

The function receives the surrounding context and returns the context to provide to the channel. The returned channel requires the services needed to build that context.

services
Source effect/Channel.ts:734320 lines
export const updateContext: {
  <Env, R2>(
    f: (context: Context.Context<R2>) => Context.Context<Env>
  ): <OutElem, OutErr, OutDone, InElem, InErr, InDone>(
    self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
  ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, R2>(
    self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
    f: (context: Context.Context<R2>) => Context.Context<Env>
  ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2>
} = dual(2, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, R2>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
  f: (context: Context.Context<R2>) => Context.Context<Env>
): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, R2> =>
  fromTransform((upstream, scope) =>
    Effect.contextWith((context) => {
      const toProvide = f(context)
      return toTransform(provideContext(self, toProvide))(upstream, scope)
    })
  ))
Referenced by 2 symbols