MCPcopy Create free account
hub / github.com/effect-app/libs / runtimePromise

Function runtimePromise

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

Source from the content-addressed store, hash-verified

901 * **Example** (Running effects as promises)
902 *
903 * ```ts import.meta.vitest
904 * import { Effect, FiberMap } from "effect"
905 *
906 * const program = Effect.gen(function*() {
907 * const map = yield* FiberMap.make<string>()
908 * const runPromise = yield* FiberMap.runtimePromise(map)<never>()
909 *
910 * // Create promises that will be backed by fibers in the map
911 * const promise1 = runPromise("task1", Effect.succeed("Hello"))
912 * const promise2 = runPromise("task2", Effect.succeed("World"))
913 *
914 * // Convert promises back to Effects and await
915 * return [yield* Effect.promise(() => promise1), yield* Effect.promise(() => promise2)]
916 * })
917 *
918 * const actual = await Effect.runPromise(Effect.scoped(program))
919 * actual // => ["Hello", "World"]
920 * ```
921 *
922 * @category combinators
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(

Callers 1

makeRuntimePromiseFunction · 0.70

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…