Event Bridge
Import
Section titled “Import”import { startEventBridge } from "webotron/plugins/event-bridge";Entry Point
Section titled “Entry Point”startEventBridge(view)
const bridge = await startEventBridge(view);
const listenerId = await bridge.on("click", (event) => { console.log("clicked:", event.target?.id);}, { selector: "#submitBtn" });
await bridge.off(listenerId);await bridge.stop();Listener Options
Section titled “Listener Options”| Option | Type | Purpose |
|---|---|---|
selector | string | Attach to a specific element. |
target | window | document | body | Attach to a global target. |
capture | boolean | Capture phase listener mode. |
passive | boolean | Passive listener mode. |
once | boolean | Auto-remove listener after first event. |
What It Does
Section titled “What It Does”- Registers a binding in the page.
- Emits structured event payloads back to the host.
- Supports selector-based, window, body, and document targets.