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

Function fromBuild

packages/effect/src/Layer.ts:333–345  ·  view source on GitHub ↗
(
  build: (
    memoMap: MemoMap,
    scope: Scope.Scope
  ) => Effect<Context.Context<ROut>, E, RIn>
)

Source from the content-addressed store, hash-verified

331 * @since 4.0.0
332 */
333export const fromBuild = <ROut, E, RIn>(
334 build: (
335 memoMap: MemoMap,
336 scope: Scope.Scope
337 ) => Effect<Context.Context<ROut>, E, RIn>
338): Layer<ROut, E, RIn> =>
339 fromBuildUnsafe((memoMap: MemoMap, scope: Scope.Scope) => {
340 const layerScope = Scope.forkUnsafe(scope)
341 return internalEffect.onExit(
342 build(memoMap, layerScope),
343 (exit) => exit._tag === "Failure" ? Scope.close(layerScope, exit) : internalEffect.void
344 )
345 })
346
347/**
348 * Constructs a `Layer` from a function that uses a `MemoMap` and `Scope` to

Callers 4

fromBuildMemoFunction · 0.85
mergeAllFunction · 0.85
provideWithFunction · 0.85
Layer.tsFile · 0.85

Calls 3

fromBuildUnsafeFunction · 0.85
buildFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected