Effection Logo

function onthefrontside/effection

function on<T extends EventTarget, K extends EventList<T> | (string & {})>(target: T, name: K): Stream<EventTypeFromEventTarget<T, K>, never>

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"

Return Type

Stream<EventTypeFromEventTarget<T, K>, never>

a stream that will see one item for each event