Helper class to handle events and turn them into async iterables
const stream = new EventStream<MouseEvent>() document.body.addEventListener('click', ev => stream.emit(ev)) wait(10e3).then(() => stream.end()) for await (const event of stream) { alert("Clicked!") }
[Symbol.asyncIterator](): AsyncGenerator<Awaited<T>, void, undefined>
Iterate over the event stream, calling a callback for each event.
Dispatches an event. For-await-of listeners of this class instance will recieve this event. Note that once an event is emitted, it cannot be cancelled.
end(): void
Stops the iterator. This terminates for-await-of loops listening for events, and any newly dispatched events will not be sent to the iterator.