mini-effect
    Preparing search index...

    Class Provide<D, T>

    An Effect that supplies a concrete value for a Dependency.

    Provide is produced by Dependency.provide and is used as a Pipeable operation inside pipe or Effect.pipe. When the pipeline executes, the Provide effect writes the supplied value into the internal dependency context so that subsequent yield* calls on the corresponding Dependency resolve to that value.

    You should not instantiate Provide directly — use Dependency.provide instead.

    import { dependency, gen, run } from "mini-effect";

    const UserName = dependency("UserName")<string>();

    const sayHello = gen(function* () {
    const name = yield* UserName;
    return `Hello, ${name}`;
    });

    // UserName.provide("Alice") returns a Provide instance
    await run(sayHello.pipe(UserName.provide("Alice")));
    // => "Hello, Alice"

    Type Parameters

    • D extends string = any

      The string literal tag identifying the dependency

    • T = any

      The type of the value being provided

    Hierarchy (View Summary)

    Index

    Constructors

    • Type Parameters

      • D extends string = any

        The string literal tag identifying the dependency

      • T = any

        The type of the value being provided

      Parameters

      • tag: D
      • instance: T

      Returns Provide<D, T>

    Properties

    "[DEPENDENCY_TYPE]": never
    "[ERROR]"?: (cause: unknown) => Effect<any, any, any, any> | undefined
    "[PROVIDER]": true
    "[PROVIDES_TYPE]": Dependency
    "[RUN]"?: Thunk<void>

    Methods

    • Composes this effect with one or more Pipeable operations into a single sequential effect.

      Type Parameters

      Parameters

      • ...pipeable: E

        One or more pipeable operations to apply after this effect

      Returns PipeReturn<[Effect<void, never, never, Dependency<D, T>>, ...E[]]>

      A new Effect representing the composed pipeline

      This is a fluent convenience method equivalent to calling the standalone pipe function with this effect as the first argument. It accepts transform functions, error handlers, and dependency providers.

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

      const result = await run(
      succeed(5).pipe(
      (n: number) => succeed(n * 2),
      (n: number) => succeed(n + 1),
      ),
      );
      // => 11