MCPcopy Create free account
hub / github.com/Effect-TS/effect / provideWith

Function provideWith

packages/effect/src/Layer.ts:1331–1350  ·  view source on GitHub ↗
(
  self: Layer<any, any, any>,
  that: Layer<any, any, any> | ReadonlyArray<Layer<any, any, any>>,
  f: (
    selfContext: Context.Context<any>,
    thatContext: Context.Context<any>
  ) => Context.Context<any>
)

Source from the content-addressed store, hash-verified

1329) => mergeAll(self, ...(Array.isArray(that) ? that : [that])))
1330
1331const provideWith = (
1332 self: Layer<any, any, any>,
1333 that: Layer<any, any, any> | ReadonlyArray<Layer<any, any, any>>,
1334 f: (
1335 selfContext: Context.Context<any>,
1336 thatContext: Context.Context<any>
1337 ) => Context.Context<any>
1338) =>
1339 fromBuild((memoMap, scope) =>
1340 internalEffect.flatMap(
1341 Array.isArray(that)
1342 ? mergeAllEffect(that as NonEmptyArray<Layer<any, any, any>>, memoMap, scope)
1343 : (that as Layer<any, any, any>).build(memoMap, scope),
1344 (context) =>
1345 self.build(memoMap, scope).pipe(
1346 internalEffect.provideContext(context),
1347 internalEffect.map((merged) => f(merged, context))
1348 )
1349 )
1350 )
1351
1352/**
1353 * Feeds the output services of the dependency layer into the requirements of

Callers 1

Layer.tsFile · 0.85

Calls 6

fromBuildFunction · 0.85
mergeAllEffectFunction · 0.85
buildMethod · 0.80
pipeMethod · 0.65
fFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected