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

Function runtimePromise

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

Source from the content-addressed store, hash-verified

923 * @since 3.13.0
924 */
925export const runtimePromise = <K, A, E>(self: FiberMap<K, A, E>): <R = never>() => Effect.Effect<
926 <XE extends E, XA extends A>(
927 key: K,
928 effect: Effect.Effect<XA, XE, R>,
929 options?:
930 | Effect.RunOptions & {
931 readonly onlyIfMissing?: boolean | undefined
932 readonly propagateInterruption?: boolean | undefined
933 }
934 | undefined
935 ) => Promise<XA>,
936 never,
937 R
938> =>
939<R>() =>
940 Effect.map(
941 runtime(self)<R>(),
942 (runFork) =>
943 <XE extends E, XA extends A>(
944 key: K,
945 effect: Effect.Effect<XA, XE, R>,
946 options?:
947 | Effect.RunOptions & { readonly propagateInterruption?: boolean | undefined }
948 | undefined
949 ): Promise<XA> =>
950 new Promise((resolve, reject) =>
951 runFork(key, effect, options).addObserver((exit) => {
952 if (Exit.isSuccess(exit)) {
953 resolve(exit.value)
954 } else {
955 reject(Cause.squash(exit.cause))
956 }
957 })
958 )
959 )
960
961/**
962 * Gets the number of fibers currently in the FiberMap.

Callers 1

makeRuntimePromiseFunction · 0.70

Calls 5

runForkFunction · 0.85
addObserverMethod · 0.80
runtimeFunction · 0.70
resolveFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected