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

Function runtimePromise

packages/effect/src/FiberSet.ts:623–652  ·  view source on GitHub ↗
(self: FiberSet<A, E>)

Source from the content-addressed store, hash-verified

621 * @since 3.13.0
622 */
623export const runtimePromise = <A, E>(self: FiberSet<A, E>): <R = never>() => Effect.Effect<
624 <XE extends E, XA extends A>(
625 effect: Effect.Effect<XA, XE, R>,
626 options?:
627 | Effect.RunOptions & { readonly propagateInterruption?: boolean | undefined }
628 | undefined
629 ) => Promise<XA>,
630 never,
631 R
632> =>
633<R>() =>
634 Effect.map(
635 runtime(self)<R>(),
636 (runFork) =>
637 <XE extends E, XA extends A>(
638 effect: Effect.Effect<XA, XE, R>,
639 options?:
640 | Effect.RunOptions & { readonly propagateInterruption?: boolean | undefined }
641 | undefined
642 ): Promise<XA> =>
643 new Promise((resolve, reject) =>
644 runFork(effect, options).addObserver((exit) => {
645 if (Exit.isSuccess(exit)) {
646 resolve(exit.value)
647 } else {
648 reject(Cause.squash(exit.cause))
649 }
650 })
651 )
652 )
653
654/**
655 * Gets the number of fibers currently in the FiberSet.

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