<Self>(): <
const Id extends string,
const Options extends
| NoExcessProperties<
{
readonly lookup: (key: any) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined
readonly preloadKeys?:
| Iterable<
Options extends { readonly lookup: (key: infer K) => any }
? K
: never
>
| undefined
},
Options
>
| NoExcessProperties<
{
readonly layers: Record<string, Layer.Layer<any, any, any>>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined
readonly preload?: boolean | undefined
},
Options
>
>(
id: Id,
options: Options
) => TagClass<
Self,
Id,
Options extends { readonly lookup: (key: infer K) => any }
? K
: Options extends { readonly layers: infer Layers }
? keyof Layers
: never,
Service.Success<Options>,
Options extends { readonly preload: true }
? never
: Service.Error<Options>,
Service.Services<Options>,
Options extends { readonly preload: true }
? Service.Error<Options>
: Options extends { readonly preloadKeys: Iterable<any> }
? Service.Error<Options>
: never,
Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>
}
? Options["dependencies"][number]
: never
>Create a LayerMap service that provides a dynamic set of resources based on
a key.
Example (Defining a layer map service)
import { Console, Context, Effect, Layer, LayerMap } from "effect"
// Define a service key
const Greeter = Context.Service<{
readonly greet: Effect.Effect<string>
}>("Greeter")
// Create a service that wraps a LayerMap
class GreeterMap extends LayerMap.Service<GreeterMap>()("GreeterMap", {
// Define the lookup function for the layer map
lookup: (name: string) =>
Layer.succeed(Greeter)({
greet: Effect.succeed(`Hello, ${name}!`)
}),
// If a layer is not used for a certain amount of time, it can be removed
idleTimeToLive: "5 seconds"
}) {}
// Usage
const program = Effect.gen(function*() {
// Access and use the Greeter service
const greeter = yield* Greeter
yield* Console.log(yield* greeter.greet)
}).pipe(
// Use the GreeterMap service to provide a variant of the Greeter service
Effect.provide(GreeterMap.get("John"))
).pipe(
// Provide the GreeterMap layer
Effect.provide(GreeterMap.layer)
)export const const Service: <Self>() => <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options) => TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Create a LayerMap service that provides a dynamic set of resources based on
a key.
Example (Defining a layer map service)
import { Console, Context, Effect, Layer, LayerMap } from "effect"
// Define a service key
const Greeter = Context.Service<{
readonly greet: Effect.Effect<string>
}>("Greeter")
// Create a service that wraps a LayerMap
class GreeterMap extends LayerMap.Service<GreeterMap>()("GreeterMap", {
// Define the lookup function for the layer map
lookup: (name: string) =>
Layer.succeed(Greeter)({
greet: Effect.succeed(`Hello, ${name}!`)
}),
// If a layer is not used for a certain amount of time, it can be removed
idleTimeToLive: "5 seconds"
}) {}
// Usage
const program = Effect.gen(function*() {
// Access and use the Greeter service
const greeter = yield* Greeter
yield* Console.log(yield* greeter.greet)
}).pipe(
// Use the GreeterMap service to provide a variant of the Greeter service
Effect.provide(GreeterMap.get("John"))
).pipe(
// Provide the GreeterMap layer
Effect.provide(GreeterMap.layer)
)
Type helpers for values created with LayerMap.Service.
Service = <function (type parameter) Self in <Self>(): <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options) => TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Self>() =>
<
const function (type parameter) Id in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Id extends string,
const function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends
| type NoExcessProperties<T, U> = T & Readonly<Record<Exclude<keyof U, keyof T>, never>>Constrains a type to prevent excess properties not present in T.
When to use
Use to catch accidental extra properties in generic functions at compile time.
Details
Extra keys from U that are not in T are mapped to never.
Example (Preventing extra properties)
import type { Types } from "effect"
type Expected = { a: number; b: string }
type Input = { a: number; b: string; c: boolean }
type Result = Types.NoExcessProperties<Expected, Input>
// { a: number; b: string; readonly c: never }
NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>lookup: (key: anykey: any) => import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>
readonly dependencies?: | ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
dependencies?: interface ReadonlyArray<T>ReadonlyArray<import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>> | undefined
readonly idleTimeToLive?: anyidleTimeToLive?: type IdleTimeToLiveInput<K> = anyIdleTimeToLiveInput<any> | undefined
readonly preloadKeys?: | Iterable<
Options extends {
readonly lookup: (key: infer K) => any
}
? K
: never
>
| undefined
preloadKeys?:
| interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly lookup: (key: infer K) => anylookup: (key: Kkey: infer function (type parameter) KK) => any } ? function (type parameter) KK : never>
| undefined
}, function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>
| type NoExcessProperties<T, U> = T & Readonly<Record<Exclude<keyof U, keyof T>, never>>Constrains a type to prevent excess properties not present in T.
When to use
Use to catch accidental extra properties in generic functions at compile time.
Details
Extra keys from U that are not in T are mapped to never.
Example (Preventing extra properties)
import type { Types } from "effect"
type Expected = { a: number; b: string }
type Input = { a: number; b: string; c: boolean }
type Result = Types.NoExcessProperties<Expected, Input>
// { a: number; b: string; readonly c: never }
NoExcessProperties<{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
layers: type Record<K extends keyof any, T> = {
[P in K]: T
}
Construct a type with a set of properties K of type T
Record<string, import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>>
readonly dependencies?: | ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
dependencies?: interface ReadonlyArray<T>ReadonlyArray<import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>> | undefined
readonly idleTimeToLive?: anyidleTimeToLive?: type IdleTimeToLiveInput<K> = anyIdleTimeToLiveInput<any> | undefined
readonly preload?: boolean | undefinedpreload?: boolean | undefined
}, function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>
>(
id: const Id extends stringid: function (type parameter) Id in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Id,
options: const Options extends NoExcessProperties<{ readonly lookup: (key: any) => Layer.Layer<any, any, any>; readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined; readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined; readonly preloadKeys?: Iterable<Options extends { readonly lookup: (key: infer K) => any; } ? K : never> | undefined; }, Options> | NoExcessProperties<{ readonly layers: Record<string, Layer.Layer<any, any, any>>; readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined; readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined; readonly preload?: boolean | undefined; }, Options>options: function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options
): interface TagClass<in out Self, in out Id extends string, in out K, in out I, in out E, in out R, in out LE, in out Deps extends Layer.Layer<any, any, any>>Service class shape produced by LayerMap.Service.
When to use
Use as the public type for classes returned by LayerMap.Service when an API
needs to accept, return, or alias the generated service class and its static
helpers.
Details
It combines a Context.Service tag for the LayerMap with default layers
and helper accessors for retrieving, using, and invalidating keyed resources.
TagClass<
function (type parameter) Self in <Self>(): <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options) => TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Self,
function (type parameter) Id in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Id,
function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly lookup: (key: infer K) => anylookup: (key: Kkey: infer function (type parameter) KK) => any } ? function (type parameter) KK
: function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly layers: Layerslayers: infer function (type parameter) LayersLayers } ? keyof function (type parameter) LayersLayers
: never,
Service.type Service.Success<Options> = Service.Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : neverExtracts the services provided by the layers in a LayerMap.Service
definition.
Success<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>,
function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly preload: truepreload: true } ? never : Service.type Service.Error<Options> = Service.Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : neverExtracts the error type of the layers in a LayerMap.Service definition.
Error<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>,
Service.type Service.Services<Options> = Service.Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : neverExtracts the service requirements of the layers in a LayerMap.Service
definition.
Services<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>,
function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly preload: truepreload: true } ? Service.type Service.Error<Options> = Service.Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : neverExtracts the error type of the layers in a LayerMap.Service definition.
Error<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>
: function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly preloadKeys: Iterable<any>preloadKeys: interface Iterable<T, TReturn = any, TNext = any>Iterable<any> } ? Service.type Service.Error<Options> = Service.Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : neverExtracts the error type of the layers in a LayerMap.Service definition.
Error<function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options>
: never,
function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options extends { readonly dependencies: ReadonlyArray<
Layer.Layer<any, any, any>
>
dependencies: interface ReadonlyArray<T>ReadonlyArray<import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>> } ? function (type parameter) Options in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Options["dependencies"][number]
: never
> => {
const const Err: anyErr = module globalThisglobalThis.var Error: ErrorConstructorError as any
const const limit: number | undefinedlimit = function getStackTraceLimit(): number | undefinedGet the current Error.stackTraceLimit value.
Returns undefined if the property doesn't exist.
getStackTraceLimit()
function setStackTraceLimit(value: number | undefined): voidSafely set Error.stackTraceLimit if possible, otherwise no-op.
Accepts undefined so a value read via
getStackTraceLimit
can be
restored faithfully.
setStackTraceLimit(2)
const const creationError: anycreationError = new const Err: anyErr()
function setStackTraceLimit(value: number | undefined): voidSafely set Error.stackTraceLimit if possible, otherwise no-op.
Accepts undefined so a value read via
getStackTraceLimit
can be
restored faithfully.
setStackTraceLimit(const limit: number | undefinedlimit)
function function (local function) TagClass(): voidTagClass() {}
const const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_ = function (local function) TagClass(): voidTagClass as any as type Mutable<T> = { -readonly [P in keyof T]: T[P]; }Removes readonly from all properties of T. Supports arrays, tuples,
and records.
When to use
Use when you need a mutable version of a readonly type.
Details
Only affects the top level; nested properties remain readonly.
Example (Converting shallowly to mutable types)
import type { Types } from "effect"
type Obj = Types.Mutable<{
readonly a: string
readonly b: ReadonlyArray<number>
}>
// { a: string; b: ReadonlyArray<number> }
// ^ mutable ^ still readonly inside
type Arr = Types.Mutable<ReadonlyArray<string>>
// string[]
type Tup = Types.Mutable<readonly [string, number]>
// [string, number]
Mutable<interface TagClass<in out Self, in out Id extends string, in out K, in out I, in out E, in out R, in out LE, in out Deps extends Layer.Layer<any, any, any>>Service class shape produced by LayerMap.Service.
When to use
Use as the public type for classes returned by LayerMap.Service when an API
needs to accept, return, or alias the generated service class and its static
helpers.
Details
It combines a Context.Service tag for the LayerMap with default layers
and helper accessors for retrieving, using, and invalidating keyed resources.
TagClass<function (type parameter) Self in <Self>(): <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options) => TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Self, function (type parameter) Id in <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options): TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Id, string, any, any, any, any, any>>
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.setPrototypeOf(o: any, proto: object | null): anySets the prototype of a specified object o to object proto or null. Returns the object o.
setPrototypeOf(function (local function) TagClass(): voidTagClass, var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.getPrototypeOf(o: any): anyReturns the prototype of an object.
getPrototypeOf(import ContextContext.Service<function (type parameter) Self in <Self>(): <const Id extends string, const Options extends NoExcessProperties<{
readonly lookup: (key: any) => Layer.Layer<any, any, any>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preloadKeys?: Iterable<Options extends {
readonly lookup: (key: infer K) => any;
} ? K : never> | undefined;
}, Options> | NoExcessProperties<{
readonly layers: Record<string, Layer.Layer<any, any, any>>;
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined;
readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined;
readonly preload?: boolean | undefined;
}, Options>>(id: Id, options: Options) => TagClass<Self, Id, Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never, Service.Success<Options>, Options extends {
readonly preload: true;
} ? never : Service.Error<Options>, Service.Services<Options>, Options extends {
readonly preload: true;
} ? Service.Error<Options> : Options extends {
readonly preloadKeys: Iterable<any>;
} ? Service.Error<Options> : never, Options extends {
readonly dependencies: ReadonlyArray<Layer.Layer<any, any, any>>;
} ? Options["dependencies"][number] : never>
Self, any>(id: const Id extends stringid)))
function (local function) TagClass(): voidTagClass.TagClass.key: const Id extends stringkey = id: const Id extends stringid
var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.defineProperty<{
(): void;
key: Id;
}>(o: {
(): void;
key: Id;
}, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): {
(): void;
key: Id;
}
Adds a property to an object, or modifies attributes of an existing property.
defineProperty(function (local function) TagClass(): voidTagClass, "stack", {
PropertyDescriptor.get?(): anyget() {
return const creationError: anycreationError.stack
}
})
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.layerNoDeps: Layer.Layer<Self, any, any>(property) layerNoDeps: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, any, any>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
A default layer for the LayerMap service without the dependencies provided.
layerNoDeps = import LayerLayer.effect(const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_)(
"lookup" in options: const Options extends NoExcessProperties<{ readonly lookup: (key: any) => Layer.Layer<any, any, any>; readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined; readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined; readonly preloadKeys?: Iterable<Options extends { readonly lookup: (key: infer K) => any; } ? K : never> | undefined; }, Options> | NoExcessProperties<{ readonly layers: Record<string, Layer.Layer<any, any, any>>; readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>> | undefined; readonly idleTimeToLive?: IdleTimeToLiveInput<any> | undefined; readonly preload?: boolean | undefined; }, Options>options
? const make: <
K,
L extends Layer.Layer<any, any, any>,
PreloadKeys extends
| Iterable<K>
| undefined = undefined
>(
lookup: (key: K) => L,
options?:
| {
readonly idleTimeToLive?:
| IdleTimeToLiveInput<K>
| undefined
readonly preloadKeys?: PreloadKeys
}
| undefined
) => Effect.Effect<
LayerMap<K, Layer.Success<L>, Layer.Error<L>>,
PreloadKeys extends undefined
? never
: Layer.Error<L>,
Scope.Scope | Layer.Services<L>
>
Creates a LayerMap that dynamically provides resources based on a key.
Example (Creating a layer map)
import { Context, Effect, Layer, LayerMap } from "effect"
// Define a service key
const DatabaseService = Context.Service<{
readonly query: (sql: string) => Effect.Effect<string>
}>("Database")
// Create a LayerMap that provides different database configurations
const program = Effect.gen(function*() {
const layerMap = yield* LayerMap.make(
(env: string) =>
Layer.succeed(DatabaseService)({
query: Effect.fn("DatabaseService.query")((sql) => Effect.succeed(`${env}: ${sql}`))
}),
{ idleTimeToLive: "5 seconds" }
)
// Get a layer for a specific environment
const devLayer = layerMap.get("development")
// Use the layer to provide the service
const result = yield* Effect.provide(
Effect.gen(function*() {
const db = yield* DatabaseService
return yield* db.query("SELECT * FROM users")
}),
devLayer
)
console.log(result) // "development: SELECT * FROM users"
})
make(options: NoExcessProperties<
{
readonly lookup: (
key: any
) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preloadKeys?:
| Iterable<
Options extends {
readonly lookup: (key: infer K) => any
}
? K
: never
>
| undefined
},
Options
>
options.lookup: (key: any) => Layer.Layer<any, any, any>lookup, options: NoExcessProperties<
{
readonly lookup: (
key: any
) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preloadKeys?:
| Iterable<
Options extends {
readonly lookup: (key: infer K) => any
}
? K
: never
>
| undefined
},
Options
>
options)
: const fromRecord: <
Layers extends Record<
string,
Layer.Layer<any, any, any>
>,
Preload extends boolean = false
>(
layers: Layers,
options?:
| {
readonly idleTimeToLive?:
| IdleTimeToLiveInput<keyof Layers>
| undefined
readonly preload?: Preload | undefined
}
| undefined
) => Effect.Effect<
LayerMap<
keyof Layers,
Layer.Success<Layers[keyof Layers]>,
Layer.Error<Layers[keyof Layers]>
>,
Preload extends true
? Layer.Error<Layers[keyof Layers]>
: never,
| Scope.Scope
| (Layers[keyof Layers] extends Layer.Layer<
infer _A,
infer _E,
infer _R
>
? _R
: never)
>
Creates a LayerMap from a record of predefined layers.
Details
The record keys become the keys accepted by the returned LayerMap, and the
record values are the layers built for those keys.
Example (Creating a layer map from a record)
import { Context, Effect, Layer, LayerMap } from "effect"
// Define service keys
const DevDatabase = Context.Service<{
readonly query: (sql: string) => Effect.Effect<string>
}>("DevDatabase")
const ProdDatabase = Context.Service<{
readonly query: (sql: string) => Effect.Effect<string>
}>("ProdDatabase")
// Create predefined layers
const layers = {
development: Layer.succeed(DevDatabase)({
query: Effect.fn("DevDatabase.query")((sql) => Effect.succeed(`DEV: ${sql}`))
}),
production: Layer.succeed(ProdDatabase)({
query: Effect.fn("ProdDatabase.query")((sql) => Effect.succeed(`PROD: ${sql}`))
})
} as const
// Create a LayerMap from the record
const program = Effect.gen(function*() {
const layerMap = yield* LayerMap.fromRecord(layers, {
idleTimeToLive: "10 seconds"
})
// Get layers by key
const devLayer = layerMap.get("development")
const prodLayer = layerMap.get("production")
console.log("LayerMap created from record")
})
fromRecord(options: NoExcessProperties<
{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preload?: boolean | undefined
},
Options
>
options.layers: Record<
string,
Layer.Layer<any, any, any>
>
layers as any, options: NoExcessProperties<
{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
readonly dependencies?:
| ReadonlyArray<Layer.Layer<any, any, any>>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preload?: boolean | undefined
},
Options
>
options) as any
)
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.layer: Layer.Layer<Self, any, unknown>(property) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, any, unknown>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
A default layer for the LayerMap service.
layer = options: | NoExcessProperties<
{
readonly lookup: (
key: any
) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preloadKeys?:
| Iterable<
Options extends {
readonly lookup: (
key: infer K
) => any
}
? K
: never
>
| undefined
},
Options
>
| NoExcessProperties<
{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preload?: boolean | undefined
},
Options
>
options.dependencies?: | readonly Layer.Layer<any, any, any>[]
| undefined
dependencies && options: | NoExcessProperties<
{
readonly lookup: (
key: any
) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preloadKeys?:
| Iterable<
Options extends {
readonly lookup: (
key: infer K
) => any
}
? K
: never
>
| undefined
},
Options
>
| NoExcessProperties<
{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preload?: boolean | undefined
},
Options
>
options.dependencies?: ReadonlyArray<
Layer.Layer<any, any, any>
>
dependencies.ReadonlyArray<Layer.Layer<any, any, any>>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length > 0 ?
import LayerLayer.provide(const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.layerNoDeps: Layer.Layer<Self, any, any>(property) layerNoDeps: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, any, any>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
A default layer for the LayerMap service without the dependencies provided.
layerNoDeps, options: | NoExcessProperties<
{
readonly lookup: (
key: any
) => Layer.Layer<any, any, any>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preloadKeys?:
| Iterable<
Options extends {
readonly lookup: (
key: infer K
) => any
}
? K
: never
>
| undefined
},
Options
>
| NoExcessProperties<
{
readonly layers: Record<
string,
Layer.Layer<any, any, any>
>
readonly dependencies?:
| ReadonlyArray<
Layer.Layer<any, any, any>
>
| undefined
readonly idleTimeToLive?:
| IdleTimeToLiveInput<any>
| undefined
readonly preload?: boolean | undefined
},
Options
>
options.dependencies?: ReadonlyArray<
Layer.Layer<any, any, any>
>
dependencies as any) :
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.layerNoDeps: Layer.Layer<Self, any, any>(property) layerNoDeps: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, any, any>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
A default layer for the LayerMap service without the dependencies provided.
layerNoDeps
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.get: (
key: string
) => Layer.Layer<any, any, Self>
Retrieves a Layer for the resources associated with the key.
get = (key: stringkey: string) => import LayerLayer.unwrap(import EffectEffect.map(const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_, (layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap) => layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap.get(key: stringkey)))
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.contextEffect: (
key: string
) => Effect.Effect<
Context.Context<any>,
any,
Scope.Scope | Self
>
Retrieves the context associated with the key.
contextEffect = (key: stringkey: string) => import EffectEffect.flatMap(const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_, (layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap) => layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap.contextEffect(key: stringkey))
const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_.invalidate: (
key: string
) => Effect.Effect<void, never, Self>
Invalidates the resource associated with the key.
invalidate = (key: stringkey: string) => import EffectEffect.flatMap(const TagClass_: Mutable<
TagClass<
Self,
Id,
string,
any,
any,
any,
any,
any
>
>
const TagClass_: {
key: Id;
Service: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: (key: string) => Layer.Layer<any, any, Self>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: (key: string) => Effect.Effect<void, never, Self>;
of: (this: void, self: LayerMap<string, any, any>) => LayerMap<string, any, any>;
context: (self: LayerMap<string, any, any>) => Context.Context<Self>;
use: (f: (service: LayerMap<string, any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerMap<string, any, any>) => A) => Effect.Effect<A, never, Self>;
Identifier: Self;
stack: string | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
TagClass_, (layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap) => layerMap: LayerMap<string, any, any>(parameter) layerMap: {
rcMap: RcMap.RcMap<K, Context.Context<I>, E>;
get: (key: string) => Layer.Layer<any, any, never>;
contextEffect: (key: string) => Effect.Effect<Context.Context<any>, any, Scope.Scope>;
invalidate: (key: string) => Effect.Effect<void>;
}
layerMap.invalidate(key: stringkey))
return function (local function) TagClass(): voidTagClass as any
}
/**
* Type helpers for values created with `LayerMap.Service`.
*
* @since 3.14.0
*/
export declare namespace Service {
/**
* Extracts the key type accepted by a `LayerMap.Service` definition.
*
* @category services
* @since 3.14.0
*/
export type type Service.Key<Options> = Options extends {
readonly lookup: (key: infer K) => any;
} ? K : Options extends {
readonly layers: infer Layers;
} ? keyof Layers : never
Extracts the key type accepted by a LayerMap.Service definition.
Key<function (type parameter) Options in type Service.Key<Options>Options> = function (type parameter) Options in type Service.Key<Options>Options extends { readonly lookup: (key: infer K) => anylookup: (key: Kkey: infer function (type parameter) KK) => any } ? function (type parameter) KK
: function (type parameter) Options in type Service.Key<Options>Options extends { readonly layers: Layerslayers: infer function (type parameter) LayersLayers } ? keyof function (type parameter) LayersLayers
: never
/**
* Extracts the layer type produced by a `LayerMap.Service` definition.
*
* @category services
* @since 3.14.0
*/
export type type Service.Layers<Options> = Options extends {
readonly lookup: (key: infer _K) => infer Layers;
} ? Layers : Options extends {
readonly layers: infer Layers;
} ? Layers[keyof Layers] : never
Extracts the layer type produced by a LayerMap.Service definition.
Layers<function (type parameter) Options in type Service.Layers<Options>Options> = function (type parameter) Options in type Service.Layers<Options>Options extends { readonly lookup: (key: infer _K) => infer Layerslookup: (key: _Kkey: infer function (type parameter) _K_K) => infer function (type parameter) LayersLayers } ? function (type parameter) LayersLayers
: function (type parameter) Options in type Service.Layers<Options>Options extends { readonly layers: Layerslayers: infer function (type parameter) LayersLayers } ? function (type parameter) LayersLayers[keyof function (type parameter) LayersLayers]
: never
/**
* Extracts the services provided by the layers in a `LayerMap.Service`
* definition.
*
* @category services
* @since 3.14.0
*/
export type type Service.Success<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : neverExtracts the services provided by the layers in a LayerMap.Service
definition.
Success<function (type parameter) Options in type Service.Success<Options>Options> = type Service.Layers<Options> = Options extends {
readonly lookup: (key: infer _K) => infer Layers;
} ? Layers : Options extends {
readonly layers: infer Layers;
} ? Layers[keyof Layers] : never
Extracts the layer type produced by a LayerMap.Service definition.
Layers<function (type parameter) Options in type Service.Success<Options>Options> extends import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) _A_A : never
/**
* Extracts the error type of the layers in a `LayerMap.Service` definition.
*
* @category services
* @since 3.14.0
*/
export type type Service.Error<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : neverExtracts the error type of the layers in a LayerMap.Service definition.
Error<function (type parameter) Options in type Service.Error<Options>Options> = type Service.Layers<Options> = Options extends {
readonly lookup: (key: infer _K) => infer Layers;
} ? Layers : Options extends {
readonly layers: infer Layers;
} ? Layers[keyof Layers] : never
Extracts the layer type produced by a LayerMap.Service definition.
Layers<function (type parameter) Options in type Service.Error<Options>Options> extends import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) _E_E : never
/**
* Extracts the service requirements of the layers in a `LayerMap.Service`
* definition.
*
* @category services
* @since 4.0.0
*/
export type type Service.Services<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : neverExtracts the service requirements of the layers in a LayerMap.Service
definition.
Services<function (type parameter) Options in type Service.Services<Options>Options> = type Service.Layers<Options> = Options extends {
readonly lookup: (key: infer _K) => infer Layers;
} ? Layers : Options extends {
readonly layers: infer Layers;
} ? Layers[keyof Layers] : never
Extracts the layer type produced by a LayerMap.Service definition.
Layers<function (type parameter) Options in type Service.Services<Options>Options> extends import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<infer function (type parameter) _A_A, infer function (type parameter) _E_E, infer function (type parameter) _R_R> ? function (type parameter) _R_R : never
}