Skip to main content


Structured concurrency and effects for JavaScript
Go to Latest
function on
import { on } from "";

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 & { })


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


Stream<EventTypeFromEventTarget<T, K>, never>

a stream that will see one item for each event