Hyperlinkv0.8.0-beta.28

Channel

Channel.provideconsteffect/Channel.ts:7295
<A, E = never, R = never>(
  layer: Layer.Layer<A, E, R> | Context.Context<A>,
  options?: { readonly local?: boolean | undefined } | undefined
): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
) => Channel<
  OutElem,
  OutErr | E,
  OutDone,
  InElem,
  InErr,
  InDone,
  Exclude<Env, A> | R
>
<
  OutElem,
  OutErr,
  OutDone,
  InElem,
  InErr,
  InDone,
  Env,
  A,
  E = never,
  R = never
>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  layer: Layer.Layer<A, E, R> | Context.Context<A>,
  options?: { readonly local?: boolean | undefined } | undefined
): Channel<
  OutElem,
  OutErr | E,
  OutDone,
  InElem,
  InErr,
  InDone,
  Exclude<Env, A> | R
>

Provides a Layer or Context to the channel, removing the corresponding service requirements.

Details

Providing a Context delegates to provideContext. Providing a Layer builds the layer in the channel scope. Use options.local to build a fresh layer instance for this provision.

services
Source effect/Channel.ts:729535 lines
export const provide: {
  <A, E = never, R = never>(
    layer: Layer.Layer<A, E, R> | Context.Context<A>,
    options?: {
      readonly local?: boolean | undefined
    } | undefined
  ): <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>
  ) => Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Exclude<Env, A> | R>
  <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E = never, R = never>(
    self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
    layer: Layer.Layer<A, E, R> | Context.Context<A>,
    options?: {
      readonly local?: boolean | undefined
    } | undefined
  ): Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Exclude<Env, A> | R>
} = dual((args) => isChannel(args[0]), <OutElem, OutErr, OutDone, InElem, InErr, InDone, Env, A, E = never, R = never>(
  self: Channel<OutElem, OutErr, OutDone, InElem, InErr, InDone, Env>,
  layer: Layer.Layer<A, E, R> | Context.Context<A>,
  options?: {
    readonly local?: boolean | undefined
  } | undefined
): Channel<OutElem, OutErr | E, OutDone, InElem, InErr, InDone, Exclude<Env, A> | R> =>
  Context.isContext(layer) ? provideContext(self, layer) : fromTransform((upstream, scope) =>
    Effect.flatMap(
      options?.local
        ? Layer.buildWithMemoMap(layer, Layer.makeMemoMapUnsafe(), scope)
        : Layer.buildWithScope(layer, scope),
      (context) =>
        Effect.map(
          Effect.provideContext(toTransform(self)(upstream, scope), context),
          Effect.provideContext(context)
        )
    )
  ))
Referenced by 1 symbols