API Reference
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
import { fromEvent } from "@graphrefly/ts/sources";
Signature
function fromEvent(
target: EventTargetLike,
type: string,
opts: FromEventOptions = {},
): Operator<never, T>
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
A source operator that emits each event as DATA.
Example
import { graph } from "@graphrefly/ts/graph";
import { fromEvent } from "@graphrefly/ts/sources";
const clicks = graph().initNode(fromEvent<MouseEvent>(button, "click"), []);
Source
packages/ts/src/graph/sources.ts