function / @typed/template

EventHandler.isEventHandler

Checks if a value is an EventHandler.

Package version
1.0.0-beta.13
Category
Event handler protocol
Since
1.0.0
Member of
EventHandler

Import

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

Access EventHandler.isEventHandler through the imported EventHandler export. Its declaration below describes the member.

This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.

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