<Self>(): <
const Id extends string,
I,
E,
R,
X,
const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [],
const Preload extends boolean = never,
SE = never,
SR = never
>(
id: Id,
options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?: Duration.Input | undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
) => TagClass<
Self,
Id,
I,
E,
R | SR,
[Preload] extends [true] ? E : never,
Deps[number]
>Creates a service class for a LayerRef.
When to use
Use when you want to name a shared layer reference as an application service and expose static helpers for providing, retrieving, and invalidating it.
Details
The returned class is a Context.Service whose value is a LayerRef. It also
includes .layer, .layerNoDeps, .get, .contextEffect, and .invalidate
helpers so callers do not need to access the LayerRef value directly.
Example (Defining a refreshable service)
import { Context, Effect, Layer, LayerRef } from "effect"
class Database extends Context.Service<Database, {
readonly query: Effect.Effect<string>
}>()("Database") {}
const databaseLayer = Layer.succeed(Database, {
query: Effect.succeed("result")
})
class DatabaseRef extends LayerRef.Service<DatabaseRef>()("DatabaseRef", {
layer: databaseLayer,
preload: true
}) {}
const program = Effect.gen(function*() {
const database = yield* Database
return yield* database.query
}).pipe(
Effect.provide(DatabaseRef.get),
Effect.provide(DatabaseRef.layer)
)export const const Service: <Self>() => <
Id extends string,
I,
E,
R,
X,
Deps extends ReadonlyArray<
Layer.Layer<any, any, any>
> = [],
Preload extends boolean = never,
SE = never,
SR = never
>(
id: Id,
options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
) => TagClass<
Self,
Id,
I,
E,
R | SR,
[Preload] extends [true] ? E : never,
Deps[number]
>
Creates a service class for a LayerRef.
When to use
Use when you want to name a shared layer reference as an application service
and expose static helpers for providing, retrieving, and invalidating it.
Details
The returned class is a Context.Service whose value is a LayerRef. It also
includes .layer, .layerNoDeps, .get, .contextEffect, and .invalidate
helpers so callers do not need to access the LayerRef value directly.
Example (Defining a refreshable service)
import { Context, Effect, Layer, LayerRef } from "effect"
class Database extends Context.Service<Database, {
readonly query: Effect.Effect<string>
}>()("Database") {}
const databaseLayer = Layer.succeed(Database, {
query: Effect.succeed("result")
})
class DatabaseRef extends LayerRef.Service<DatabaseRef>()("DatabaseRef", {
layer: databaseLayer,
preload: true
}) {}
const program = Effect.gen(function*() {
const database = yield* Database
return yield* database.query
}).pipe(
Effect.provide(DatabaseRef.get),
Effect.provide(DatabaseRef.layer)
)
Service = <function (type parameter) Self in <Self>(): <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}) => TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Self>() =>
<
const function (type parameter) Id in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Id extends string,
function (type parameter) I in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
I,
function (type parameter) E in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
E,
function (type parameter) R in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
R,
function (type parameter) X in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
X,
const function (type parameter) Deps in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Deps extends interface ReadonlyArray<T>ReadonlyArray<import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<any, any, any>> = [],
const function (type parameter) Preload in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Preload extends boolean = never,
function (type parameter) SE in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
SE = never,
function (type parameter) SR in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
SR = never
>(
id: const Id extends stringid: function (type parameter) Id in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Id,
options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options: {
/**
* Layer used to build the cached context.
*/
readonly layer: Layer.Layer<I, E, R>(property) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<I>, E, 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; <…;
}
Layer used to build the cached context.
layer: import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<function (type parameter) I in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
I, function (type parameter) E in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
E, function (type parameter) R in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
R>
/**
* Layers used to satisfy dependencies of the `LayerRef` service layer.
*/
readonly dependencies?: Deps | undefinedLayers used to satisfy dependencies of the LayerRef service layer.
dependencies?: function (type parameter) Deps in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Deps | undefined
/**
* Duration to keep the resource alive after it is no longer used.
*/
readonly idleTimeToLive?: Duration.Input | undefinedDuration to keep the resource alive after it is no longer used.
idleTimeToLive?: import DurationDuration.type Duration.Input = /*unresolved*/ anyInput | undefined
/**
* Whether to acquire the resource during creation.
*/
readonly preload?: Preload | undefinedWhether to acquire the resource during creation.
preload?: function (type parameter) Preload in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Preload | undefined
/**
* Schedule used to invalidate the cached resource. When `preload` is
* `true`, each scheduled invalidation also reacquires the resource.
*/
readonly invalidationSchedule?: | Schedule.Schedule<X, unknown, SE, SR>
| undefined
Schedule used to invalidate the cached resource. When preload is
true, each scheduled invalidation also reacquires the resource.
invalidationSchedule?: import ScheduleSchedule.interface Schedule<out Output, in Input = unknown, out Error = never, out Env = never>A Schedule defines a strategy for repeating or retrying effects based on some policy.
Example (Defining retry and repeat schedules)
import { Console, Data, Effect, Schedule } from "effect"
class NetworkError extends Data.TaggedError("NetworkError")<{
readonly attempt: number
}> {}
// Basic retry schedule - retry up to 3 times with exponential backoff
const retrySchedule = Schedule.max([
Schedule.exponential("100 millis"),
Schedule.recurs(3)
])
// Basic repeat schedule - repeat every 30 seconds forever
const repeatSchedule: Schedule.Schedule<number, unknown, never> = Schedule
.spaced("30 seconds")
const program = Effect.gen(function*() {
let attempts = 0
const result1 = yield* Effect.retry(
Effect.gen(function*() {
attempts++
if (attempts < 3) {
return yield* Effect.fail(new NetworkError({ attempt: attempts }))
}
return "Success"
}),
retrySchedule
)
console.log(result1) // "Success"
yield* Console.log("heartbeat").pipe(
Effect.repeat(repeatSchedule.pipe(Schedule.upTo({ times: 5 })))
)
})
The Schedule namespace contains types and utilities for working with schedules.
Schedule<function (type parameter) X in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
X, unknown, function (type parameter) SE in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
SE, function (type parameter) SR in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
SR> | undefined
}
): interface TagClass<in out Self, in out Id extends string, 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 LayerRef.Service.
When to use
Use as the public type for classes returned by LayerRef.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 LayerRef with default layers and
helper accessors for retrieving, using, and invalidating the cached resource.
TagClass<
function (type parameter) Self in <Self>(): <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}) => TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Self,
function (type parameter) Id in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Id,
function (type parameter) I in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
I,
function (type parameter) E in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
E,
function (type parameter) R in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
R | function (type parameter) SR in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
SR,
[function (type parameter) Preload in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Preload] extends [true] ? function (type parameter) E in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
E : never,
function (type parameter) Deps in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Deps[number]
> => {
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, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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 I, in out E, in out R, in out LE, in out Deps extends Layer.Layer<any, any, any>>Service class shape produced by LayerRef.Service.
When to use
Use as the public type for classes returned by LayerRef.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 LayerRef with default layers and
helper accessors for retrieving, using, and invalidating the cached resource.
TagClass<function (type parameter) Self in <Self>(): <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}) => TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Self, function (type parameter) Id in <const Id extends string, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}): TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
Id, 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, I, E, R, X, const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = [], const Preload extends boolean = never, SE = never, SR = never>(id: Id, options: {
readonly layer: Layer.Layer<I, E, R>;
readonly dependencies?: Deps | undefined;
readonly idleTimeToLive?: Duration.Input | undefined;
readonly preload?: Preload | undefined;
readonly invalidationSchedule?: Schedule.Schedule<X, unknown, SE, SR> | undefined;
}) => TagClass<Self, Id, I, E, R | SR, [Preload] extends [true] ? E : never, Deps[number]>
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, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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; <…;
}
Default layer for the LayerRef service without provided dependencies.
layerNoDeps = import LayerLayer.effect(const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_)(
const make: <
I,
E,
R,
X,
Preload extends boolean = never,
SE = never,
SR = never
>(
layer: Layer.Layer<I, E, R>,
options?:
| {
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
| undefined
) => Effect.Effect<
LayerRef<I, E>,
[Preload] extends [true] ? E : never,
Scope.Scope | R | SR
>
Creates a LayerRef from a Layer.
When to use
Use when you have one layer-built resource that should be shared, optionally
kept alive while idle, and refreshed on demand.
Details
The layer is built lazily on first use unless preload is true.
idleTimeToLive keeps the context cached after it stops being used, and
invalidationSchedule can periodically invalidate it. When preload is
true, scheduled invalidation also reacquires the context.
Gotchas
Invalidation does not revoke contexts already borrowed by active scopes; those
contexts remain usable until their scopes close.
Example (Sharing one layer-built service)
import { Context, Effect, Layer, LayerRef } from "effect"
class Database extends Context.Service<Database, {
readonly query: Effect.Effect<string>
}>()("Database") {}
const databaseLayer = Layer.succeed(Database, {
query: Effect.succeed("result")
})
const query = Effect.gen(function*() {
const database = yield* Database
return yield* database.query
})
const program = Effect.scoped(
Effect.gen(function*() {
const ref = yield* LayerRef.make(databaseLayer, {
idleTimeToLive: "5 seconds"
})
const result = yield* Effect.provide(query, ref.get)
yield* ref.invalidate
return result
})
)
make(options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options.layer: Layer.Layer<I, E, R>(property) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<I>, E, 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; <…;
}
Layer used to build the cached context.
layer, options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options)
)
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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; <…;
}
Default layer for the LayerRef service, with dependencies applied.
layer = options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options.dependencies?: Deps | undefinedLayers used to satisfy dependencies of the LayerRef service layer.
dependencies && options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options.dependencies?: const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = []Layers used to satisfy dependencies of the LayerRef service layer.
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, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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; <…;
}
Default layer for the LayerRef service without provided dependencies.
layerNoDeps, options: {
readonly layer: Layer.Layer<I, E, R>
readonly dependencies?: Deps | undefined
readonly idleTimeToLive?:
| Duration.Input
| undefined
readonly preload?: Preload | undefined
readonly invalidationSchedule?:
| Schedule.Schedule<X, unknown, SE, SR>
| undefined
}
options.dependencies?: const Deps extends ReadonlyArray<Layer.Layer<any, any, any>> = []Layers used to satisfy dependencies of the LayerRef service layer.
dependencies as any) :
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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; <…;
}
Default layer for the LayerRef service without provided dependencies.
layerNoDeps
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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: Layer.Layer<any, any, Self>(property) get: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<any>, any, Self>;
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; <…;
}
Layer that provides the currently cached context, requiring this service.
get = import LayerLayer.unwrap(const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_.useSync((ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref) => ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref.get))
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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: Effect.Effect<
Context.Context<any>,
any,
Scope.Scope | Self
>
(property) contextEffect: {
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;
}
Scoped effect that retrieves the currently cached context through this service.
contextEffect = const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_.use((ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref) => ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref.contextEffect)
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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: Effect.Effect<void, never, Self>(property) invalidate: {
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;
}
Invalidates the cached context through this service.
invalidate = const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_.use((ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref) => ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref.invalidate)
const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_.refresh: Effect.Effect<void, any, Self>(property) refresh: {
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;
}
Invalidates the cached context through this service, and reacquires it.
refresh = const TagClass_: Mutable<
TagClass<Self, Id, any, any, any, any, any>
>
const TagClass_: {
key: Id;
Service: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
};
layer: Layer.Layer<Self, any, unknown>;
layerNoDeps: Layer.Layer<Self, any, any>;
get: Layer.Layer<any, any, Self>;
contextEffect: Effect.Effect<Context.Context<any>, any, Scope.Scope | Self>;
invalidate: Effect.Effect<void, never, Self>;
refresh: Effect.Effect<void, any, Self>;
of: (this: void, self: LayerRef<any, any>) => LayerRef<any, any>;
context: (self: LayerRef<any, any>) => Context.Context<Self>;
use: (f: (service: LayerRef<any, any>) => Effect.Effect<A, E, R>) => Effect.Effect<A, E, Self | R>;
useSync: (f: (service: LayerRef<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_.use((ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref) => ref: LayerRef<any, any>(parameter) ref: {
rcRef: RcRef.RcRef<Context.Context<I>, E>;
get: Layer.Layer<I, E>;
contextEffect: Effect.Effect<Context.Context<I>, E, Scope.Scope>;
invalidate: Effect.Effect<void>;
refresh: Effect.Effect<void, E>;
}
ref.refresh)
return function (local function) TagClass(): voidTagClass as any
}