function / @typed/template/EventHandler

isEventHandler

Checks if a value is an EventHandler.

Package version
1.0.0-beta.7
Category
Event handler protocol
Since
1.0.0

Import

import { isEventHandler } from "@typed/template/EventHandler";

Signatures

export declare function isEventHandler<Ev extends Event, E = never, R = never>(handler: unknown): handler is EventHandler<Ev, E, R>;

Why

The nominal key distinguishes handler descriptions from arbitrary functions before template compilation.

Ownership and lifetime

The guard only inspects the value and acquires nothing.

Examples

import * as EventHandler from "@typed/template/EventHandler"

const handler = EventHandler.make((event) => console.log("Click"))
const isHandler = EventHandler.isEventHandler(handler)
console.log(isHandler) // true

const notHandler = (event: Event) => console.log("Click")
const isNotHandler = EventHandler.isEventHandler(notHandler)
console.log(isNotHandler) // false

Other public imports

These import paths expose the same declaration. Each page retains its own public name and signature.

Source