Import
import { provide } from "@typed/template/EventHandler";Signatures
export declare const provide: {
<R2 = never>(services: Context.Context<R2>): <Ev extends Event, E = never, R = never>(handler: EventHandler<Ev, E, R>) => EventHandler<Ev, E, Exclude<R, R2>>;
<Ev extends Event, E = never, R = never, R2 = never>(handler: EventHandler<Ev, E, R>, services: Context.Context<R2>): EventHandler<Ev, E, Exclude<R, R2>>;
};Why
Providing a Context at the handler boundary narrows its required-service
channel while preserving the delegated event proxy and listener options.
Ownership and lifetime
The supplied services are captured by the returned description. Listener and handler-fiber lifetime still belong to the renderer’s Scope.
Examples
import { Effect, Context } from "effect"
import * as EventHandler from "@typed/template/EventHandler"
interface Database {
readonly save: (data: string) => Effect.Effect<void>
}
const Database = Context.Service<Database>("Database")
const handler = EventHandler.make((_event) => Effect.gen(function* () {
const database = yield* Database
yield* database.save("data")
}))
// Provide services
const services = Context.make(Database, {
save: (data) => Effect.sync(() => console.log(data))
})
const provided = EventHandler.provide(handler, services)Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.