TagClass<Self, Id, K, I, E, R, LE, Deps>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.
export interface 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<
in out function (type parameter) Self in 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>>Self,
in out function (type parameter) Id in 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>>Id extends string,
in out function (type parameter) K in 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>>K,
in out function (type parameter) I in 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>>I,
in out function (type parameter) E in 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>>E,
in out function (type parameter) R in 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>>R,
in out function (type parameter) LE in 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>>LE,
in out function (type parameter) Deps in 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>>Deps extends import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>
> extends import ContextContext.ServiceClass<function (type parameter) Self in 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>>Self, function (type parameter) Id in 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>>Id, interface LayerMap<in out K, in out I, in out E = never>A scoped, keyed map of layer-built service contexts.
Details
A LayerMap builds resources for a key on demand, exposes them as a Layer
or scoped Context, and can invalidate cached resources for a key.
Example (Managing keyed layers)
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 createDatabaseLayerMap = LayerMap.make((env: string) =>
Layer.succeed(DatabaseService)({
query: Effect.fn("DatabaseService.query")((sql) => Effect.succeed(`${env}: ${sql}`))
})
)
// Use the LayerMap
const program = Effect.gen(function*() {
const layerMap = yield* createDatabaseLayerMap
// Get a layer for a specific environment
const devLayer = layerMap.get("development")
// Get context directly
const context = yield* layerMap.contextEffect("production")
// Invalidate a cached layer
yield* layerMap.invalidate("development")
})
LayerMap<function (type parameter) K in 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>>K, function (type parameter) I in 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>>I, function (type parameter) E in 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>>E>> {
/**
* A default layer for the `LayerMap` service.
*/
readonly 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>>.layer: 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)>(property) 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>>.layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, LE | (Deps extends Layer<infer _A, infer _E, infer _R> ? _E : never), Exclude<R, Deps extends Layer<infer _A, infer _E, infer _R> ? _A : never> | (Deps extends Layer<i…;
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: import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<
function (type parameter) Self in 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>>Self,
(function (type parameter) Deps in 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>>Deps 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) | function (type parameter) LE in 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>>LE,
| type Exclude<T, U> = T extends U
? never
: T
Exclude from T those types that are assignable to U
Exclude<function (type parameter) R in 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>>R, (function (type parameter) Deps in 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>>Deps 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)>
| (function (type parameter) Deps in 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>>Deps 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)
>
/**
* A default layer for the `LayerMap` service without the dependencies provided.
*/
readonly 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>>.layerNoDeps: Layer.Layer<Self, LE, R>(property) 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>>.layerNoDeps: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<Self>, LE, R>;
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.type Layer.Layer = /*unresolved*/ anyLayer<function (type parameter) Self in 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>>Self, function (type parameter) LE in 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>>LE, function (type parameter) R in 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>>R>
/**
* Retrieves a Layer for the resources associated with the key.
*/
readonly 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>>.get: (key: K) => Layer.Layer<I, E, Self>Retrieves a Layer for the resources associated with the key.
get: (key: in out Kkey: function (type parameter) K in 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>>K) => import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<function (type parameter) I in 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>>I, function (type parameter) E in 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>>E, function (type parameter) Self in 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>>Self>
/**
* Retrieves the context associated with the key.
*/
readonly 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>>.contextEffect: (key: K) => Effect.Effect<Context.Context<I>, E, Scope.Scope | Self>Retrieves the context associated with the key.
contextEffect: (key: in out Kkey: function (type parameter) K in 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>>K) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<import ContextContext.type Context.Context = /*unresolved*/ anyContext<function (type parameter) I in 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>>I>, function (type parameter) E in 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>>E, import ScopeScope.Scope | function (type parameter) Self in 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>>Self>
/**
* Invalidates the resource associated with the key.
*/
readonly 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>>.invalidate: (key: K) => Effect.Effect<void, never, Self>Invalidates the resource associated with the key.
invalidate: (key: in out Kkey: function (type parameter) K in 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>>K) => import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<void, never, function (type parameter) Self in 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>>Self>
}