Key<Identifier, Shape>Typed identifier for a service stored in a Context.
When to use
Use as the typed handle for storing, retrieving, and requiring a specific
service in a Context.
Details
Identifier tracks the requirement in Effect types, while Shape is the
service implementation retrieved by the key. A key is also an Effect value,
so yielding it inside Effect.gen retrieves the service from the current
fiber context.
export interface interface Key<out Identifier, out Shape>Typed identifier for a service stored in a Context.
When to use
Use as the typed handle for storing, retrieving, and requiring a specific
service in a Context.
Details
Identifier tracks the requirement in Effect types, while Shape is the
service implementation retrieved by the key. A key is also an Effect value,
so yielding it inside Effect.gen retrieves the service from the current
fiber context.
Key<out function (type parameter) Identifier in Key<out Identifier, out Shape>Identifier, out function (type parameter) Shape in Key<out Identifier, out Shape>Shape> extends interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) Shape in Key<out Identifier, out Shape>Shape, never, function (type parameter) Identifier in Key<out Identifier, out Shape>Identifier> {
readonly [const ServiceTypeId: ServiceTypeIdString literal type used as the runtime type identifier for Context
service keys.
Runtime type identifier attached to Context service keys and used by
isKey to recognize them.
ServiceTypeId]: type ServiceTypeId =
"~effect/Context/Service"
String literal type used as the runtime type identifier for Context
service keys.
Runtime type identifier attached to Context service keys and used by
isKey to recognize them.
ServiceTypeId
readonly Key<out Identifier, out Shape>.Service: out ShapeService: function (type parameter) Shape in Key<out Identifier, out Shape>Shape
readonly type Identifier: out IdentifierIdentifier: function (type parameter) Identifier in Key<out Identifier, out Shape>Identifier
readonly Key<out Identifier, out Shape>.key: stringkey: string
readonly Key<out Identifier, out Shape>.stack?: string | undefinedstack?: string | undefined
}