(impl: PollingService): Layer.Layer<PollingTag>A custom cadence policy as a polling layer for Process.make({ polling }).
Replaces the old Layer.succeed(Polling, impl) form; the tag stays internal.
export const const layer: (
impl: PollingService
) => Layer.Layer<PollingTag>
A custom cadence policy as a polling layer for Process.make({ polling }).
Replaces the old Layer.succeed(Polling, impl) form; the tag stays internal.
layer = (impl: PollingServiceimpl: import PollingServicePollingService): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<import PollingTagPollingTag> =>
import registerPollingLayerregisterPollingLayer(import LayerLayer.const succeed: <unknown, unknown>(service: Key<unknown, unknown>, resource: unknown) => Layer.Layer<unknown, never, never> (+1 overload)Constructs a layer that provides a single service from an already available
value.
When to use
Use when you need a Layer that provides a service from an already
constructed implementation without effectful acquisition.
Example (Creating a layer from a service implementation)
import { Context, Effect, Layer } from "effect"
class Database extends Context.Service<Database, {
readonly query: (sql: string) => Effect.Effect<string>
}>()("Database") {}
const DatabaseLive = Layer.succeed(Database, {
query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Query result: ${sql}`))
})
succeed(import PollingTagPollingTag, impl: PollingServiceimpl));