Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/effection/lib/mod.ts>on

Structured concurrency and effects for JavaScript
Latest
function on
import { on } from "https://deno.land/x/effection@4.0.0-alpha.1/lib/mod.ts";

Create a Stream of events from any EventTarget.

See the guide on Streams and Subscriptions for details on how to use streams.

Type Parameters

T extends EventTarget
K extends EventList<T> | (string & { })

Parameters

target: T
  • the event target whose events will be streamed
name: K
  • the name of the event to stream. E.g. "click"

Returns

Stream<EventTypeFromEventTarget<T, K>, never>

a stream that will see one item for each event