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

Function fromBuild

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

Source from the content-addressed store, hash-verified

358 * @since 4.0.0
359 */
360export const fromBuild = <ROut, E, RIn>(
361 build: (
362 memoMap: MemoMap,
363 scope: Scope.Scope
364 ) => Effect<Context.Context<ROut>, E, RIn>
365): Layer<ROut, E, RIn> =>
366 fromBuildUnsafe((memoMap: MemoMap, scope: Scope.Scope) => {
367 const layerScope = Scope.forkUnsafe(scope)
368 return internalEffect.onExit(
369 build(memoMap, layerScope),
370 (exit) => exit._tag === "Failure" ? Scope.close(layerScope, exit) : internalEffect.void
371 )
372 })
373
374/**
375 * Constructs a `Layer` from a function that uses a `MemoMap` and `Scope` to

Callers 2

fromBuildMemoFunction · 0.85
Layer.tsFile · 0.85

Calls 4

fromBuildUnsafeFunction · 0.85
onExitMethod · 0.80
buildFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected