Hyperlinkv0.8.0-beta.28

Channel

Channel.updateServiceconsteffect/Channel.ts:7375
<I, S>(key: Context.Key<I, S>, f: (service: NoInfer<S>) => S): <
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone,
  Env
>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
  service: Context.Key<I, S>,
  f: (service: NoInfer<S>) => S
): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>

Updates a service in the current context before running the channel.

Details

The existing service is read from the context. The updated service is provided to the channel under the same key.

services
Source effect/Channel.ts:737523 lines
export const updateService: {
  <I, S>(
    key: Context.Key<I, S>,
    f: (service: NoInfer<S>) => S
  ): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
    self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>
  ) => Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
    self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
    service: Context.Key<I, S>,
    f: (service: NoInfer<S>) => S
  ): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I>
} = dual(3, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S>(
  self: Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env>,
  service: Context.Key<I, S>,
  f: (service: NoInfer<S>) => S
): Channel<OutElem, InElem, OutErr, InErr, OutDone, InDone, Env | I> =>
  updateContext(self, (context) =>
    Context.add(
      context,
      service,
      f(Context.get(context, service))
    )))