fromEvent()
Wrap a DOM-style event target. Each event becomes DATA; deactivation removes the listener. External callbacks are source boundaries (D43), so no polling or operator-level async leaks in.
Import
Section titled “Import”import { fromEvent } from "@graphrefly/ts/sources";Signature
Section titled “Signature”function fromEvent( target: EventTargetLike, type: string, opts: FromEventOptions = {},): Operator<never, T>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target | EventTargetLike | Event target implementing addEventListener and removeEventListener. |
type | string | Event type to subscribe to. |
opts | FromEventOptions | Optional listener options and source options. |
Returns
Section titled “Returns”A source operator that emits each event as DATA.
Example
Section titled “Example”import { graph } from "@graphrefly/ts/graph";import { fromEvent } from "@graphrefly/ts/sources";
const clicks = graph().initNode(fromEvent<MouseEvent>(button, "click"), []);Source
Section titled “Source”packages/ts/src/graph/sources.ts