LayerMap.ts overview
Since v3.14.0
Exports Grouped by Category
Constructors
fromRecord
Signature
declare const fromRecord: <
const Layers extends Record<string, Layer.Layer<any, any, any>>,
const Preload extends boolean = false
>(
layers: Layers,
options?:
| { readonly idleTimeToLive?: Duration.DurationInput | undefined; readonly preload?: Preload | undefined }
| undefined
) => Effect.Effect<
LayerMap<
keyof Layers,
Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : never,
Preload extends true ? never : Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never
>,
Preload extends true ? never : Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never,
Scope.Scope | (Layers[keyof Layers] extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never)
>
Since v3.14.0
make
Signature
declare const make: <K, L extends Layer.Layer<any, any, any>, PreloadKeys extends Iterable<K> | undefined = undefined>(
lookup: (key: K) => L,
options?:
| { readonly idleTimeToLive?: Duration.DurationInput | undefined; readonly preloadKeys?: PreloadKeys }
| undefined
) => Effect.Effect<
LayerMap<
K,
L extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : never,
L extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never
>,
PreloadKeys extends undefined ? never : L extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never,
Scope.Scope | (L extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never)
>
Since v3.14.0
Models
LayerMap (interface)
Signature
export interface LayerMap<in K, in out I, out E = never> {
readonly [TypeId]: TypeId
/**
* The internal RcMap that stores the resources.
*/
readonly rcMap: RcMap.RcMap<
K,
{
readonly layer: Layer.Layer<I, E>
readonly runtimeEffect: Effect.Effect<Runtime.Runtime<I>, E, Scope.Scope>
},
E
>
/**
* Retrieves a Layer for the resources associated with the key.
*/
get(key: K): Layer.Layer<I, E>
/**
* Retrieves a Runtime for the resources associated with the key.
*/
runtime(key: K): Effect.Effect<Runtime.Runtime<I>, E, Scope.Scope>
/**
* Invalidates the resource associated with the key.
*/
invalidate(key: K): Effect.Effect<void>
}
Since v3.14.0
Service
Service
Signature
declare const Service: <Self>() => <
const Id extends string,
Options extends
| NoExcessProperties<
{
readonly lookup: (key: any) => Layer.Layer<any, any, any>
readonly dependencies?: ReadonlyArray<Layer.Layer<any, any, any>>
readonly idleTimeToLive?: Duration.DurationInput | 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>>
readonly idleTimeToLive?: Duration.DurationInput | undefined
readonly preload?: boolean
},
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.Context<Options>,
Options extends { readonly preload: true }
? Service.Error<Options>
: Options extends { readonly preloadKey: Iterable<any> }
? Service.Error<Options>
: never,
Options extends { readonly dependencies: ReadonlyArray<any> } ? Options["dependencies"][number] : never
>
Since v3.14.0
Service (namespace)
Since v3.14.0
Key (type alias)
Signature
type Key<Options> = Options extends { readonly lookup: (key: infer K) => any }
? K
: Options extends { readonly layers: infer Layers }
? keyof Layers
: never
Since v3.14.0
Layers (type alias)
Signature
type Layers<Options> = Options extends { readonly lookup: (key: infer _K) => infer Layers }
? Layers
: Options extends { readonly layers: infer Layers }
? Layers[keyof Layers]
: never
Since v3.14.0
Success (type alias)
Signature
type Success<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : never
Since v3.14.0
Error (type alias)
Signature
type Error<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never
Since v3.14.0
Context (type alias)
Signature
type Context<Options> = Layers<Options> extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never
Since v3.14.0
TagClass (interface)
Signature
export 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>
> extends Context.TagClass<Self, Id, LayerMap<K, I, E>> {
/**
* A default layer for the `LayerMap` service.
*/
readonly Default: Layer.Layer<
Self,
(Deps extends Layer.Layer<infer _A, infer _E, infer _R> ? _E : never) | LE,
| Exclude<R, Deps extends Layer.Layer<infer _A, infer _E, infer _R> ? _A : never>
| (Deps extends Layer.Layer<infer _A, infer _E, infer _R> ? _R : never)
>
/**
* A default layer for the `LayerMap` service without the dependencies provided.
*/
readonly DefaultWithoutDependencies: Layer.Layer<Self, LE, R>
/**
* Retrieves a Layer for the resources associated with the key.
*/
readonly get: (key: K) => Layer.Layer<I, E, Self>
/**
* Retrieves a Runtime for the resources associated with the key.
*/
readonly runtime: (key: K) => Effect.Effect<Runtime.Runtime<I>, E, Scope.Scope | Self>
/**
* Invalidates the resource associated with the key.
*/
readonly invalidate: (key: K) => Effect.Effect<void, never, Self>
}
Since v3.14.0
Symbols
TypeId
Signature
declare const TypeId: unique symbol
Since v3.14.0
TypeId (type alias)
Signature
type TypeId = typeof TypeId
Since v3.14.0