mini-effect
    Preparing search index...

    Function run

    • Executes an Effect and returns a Promise that resolves with the success value or rejects with the error.

      Type Parameters

      • T

        The success value type of the effect

      • E

        The error type of the effect

      Parameters

      • effect: Effect<T, E, never, never>

        The effect to execute. Must have all dependencies satisfied (never).

      • Optionalsignal: AbortSignal

        An optional AbortSignal used to cancel the running effect

      • Optionalctx: Record<string, unknown>

      Returns Promise<T>

      A Promise that resolves with the effect's success value

      This is the only way to "escape" the Effect system and obtain a concrete value. An optional AbortSignal can be passed to support cancellation — when the signal is aborted, the abort propagates to every running thunk created by fn.

      All dependencies required by the effect must be provided (via Dependency.provide) before calling run; otherwise the effect will reject with Error("Missing dependency: <tag>").

      import { succeed, run } from "mini-effect";

      const result = await run(succeed(42));
      // => 42
      import { fn, run } from "mini-effect";

      const controller = new AbortController();
      const result = await run(fn(() => "hello"), controller.signal);
      // => "hello"