FuncType - v1.21.0
    Preparing search index...

    Interface Layer<RIn, E, ROut>

    A Layer describes how to build a service or set of services.

    // A layer that provides a Logger service
    const LoggerLive = Layer.succeed(Logger, consoleLogger)

    // A layer that requires Config and provides Database
    const DatabaseLive = Layer.fromFunction(Database, (config: Config) =>
    createDatabase(config.connectionString)
    )
    interface Layer<RIn extends Type, E extends Type, ROut extends Type> {
        _E?: E;
        _ROut?: ROut;
        map<ROut2 extends unknown>(
            f: (ctx: Context<ROut>) => Context<ROut2>,
        ): Layer<RIn, E, ROut2>;
        merge<RIn2 extends unknown, E2 extends unknown, ROut2 extends unknown>(
            that: Layer<RIn2, E2, ROut2>,
        ): Layer<RIn | RIn2, E | E2, ROut | ROut2>;
        provideToAndMerge<
            RIn2 extends unknown,
            E2 extends unknown,
            ROut2 extends unknown,
        >(
            that: Layer<ROut | RIn2, E2, ROut2>,
        ): Layer<RIn | Exclude<RIn2, ROut>, E | E2, ROut | ROut2>;
        toString(): string;
    }

    Type Parameters

    • RIn extends Type

      Required services (dependencies)

    • E extends Type

      Possible errors during construction

    • ROut extends Type

      Services provided by this layer

    Index
    _E?: E
    _ROut?: ROut
    • Composes this layer with another, running them in sequence. The output of this layer becomes available to the next layer.

      Type Parameters

      • RIn2 extends unknown
      • E2 extends unknown
      • ROut2 extends unknown

      Parameters

      Returns Layer<RIn | Exclude<RIn2, ROut>, E | E2, ROut | ROut2>

    • String representation

      Returns string