Hyperlinkv0.8.0-beta.28

Channel

Channel.provideServiceEffectconsteffect/Channel.ts:7258
<I, S, ES, RS>(
  key: Context.Key<I, S>,
  service: Effect.Effect<NoInfer<S>, ES, RS>
): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
) => Channel<
  OutElem,
  OutErr | ES,
  OutDone,
  InElem,
  InErr,
  InDone,
  Exclude<Env, I> | RS
>
<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  key: Context.Key<I, S>,
  service: Effect.Effect<NoInfer<S>, ES, RS>
): Channel<
  OutElem,
  OutErr | ES,
  OutDone,
  InElem,
  InErr,
  InDone,
  Exclude<Env, I> | RS
>

Provides a service to the channel after obtaining it from an effect.

When to use

Use to supply a channel dependency when constructing the service itself is effectful or can fail.

Details

If the service effect fails, the returned channel fails. The provided service removes the corresponding service requirement from the returned channel.

services
Source effect/Channel.ts:725823 lines
export const provideServiceEffect: {
  <I, S, ES, RS>(
    key: Context.Key<I, S>,
    service: Effect.Effect<NoInfer<S>, ES, RS>
  ): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
  ) => Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
    key: Context.Key<I, S>,
    service: Effect.Effect<NoInfer<S>, ES, RS>
  ): Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS>
} = dual(3, <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, I, S, ES, RS>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  key: Context.Key<I, S>,
  service: Effect.Effect<NoInfer<S>, ES, RS>
): Channel<OutElem, OutErr | ES, OutDone, InElem, InErr, InDone, Exclude<Env, I> | RS> =>
  fromTransform((upstream, scope) =>
    Effect.flatMap(
      service,
      (s) => toTransform(provideService(self, key, s))(upstream, scope)
    )
  ))
Referenced by 3 symbols