MCPcopy Index your code
hub / github.com/Effect-TS/effect / runtimePromise

Function runtimePromise

packages/effect/src/FiberMap.ts:580–614  ·  view source on GitHub ↗
(self: FiberMap<K, A, E>)

Source from the content-addressed store, hash-verified

578 * @categories combinators
579 */
580export const runtimePromise = <K, A, E>(self: FiberMap<K, A, E>): <R = never>() => Effect.Effect<
581 <XE extends E, XA extends A>(
582 key: K,
583 effect: Effect.Effect<XA, XE, R>,
584 options?:
585 | Runtime.RunForkOptions & {
586 readonly onlyIfMissing?: boolean | undefined
587 readonly propagateInterruption?: boolean | undefined
588 }
589 | undefined
590 ) => Promise<XA>,
591 never,
592 R
593> =>
594<R>() =>
595 Effect.map(
596 runtime(self)<R>(),
597 (runFork) =>
598 <XE extends E, XA extends A>(
599 key: K,
600 effect: Effect.Effect<XA, XE, R>,
601 options?:
602 | Runtime.RunForkOptions & { readonly propagateInterruption?: boolean | undefined }
603 | undefined
604 ): Promise<XA> =>
605 new Promise((resolve, reject) =>
606 runFork(key, effect, options).addObserver((exit) => {
607 if (Exit.isSuccess(exit)) {
608 resolve(exit.value)
609 } else {
610 reject(Cause.squash(exit.cause))
611 }
612 })
613 )
614 )
615
616/**
617 * @since 2.0.0

Callers 1

makeRuntimePromiseFunction · 0.70

Calls 5

resolveFunction · 0.85
runtimeFunction · 0.70
runForkFunction · 0.70
mapMethod · 0.65
addObserverMethod · 0.65

Tested by

no test coverage detected