import type { Operation, Stream } from "./types.js"; type FN = (...any: any[]) => any; type EventTypeFromEventTarget = `on${K}` extends keyof T ? Parameters>[0] : Event; /** * @ignore */ export type EventList = T extends { addEventListener(type: infer P, ...args: any): void; addEventListener(type: infer P2, ...args: any): void; } ? P & string : never; /** * Create an {@link Operation} that yields the next event to be emitted by an * [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). * * @example * ```ts * // wait for connection establishment before proceeding * yield* once(socket, "open"); * ``` * * @param target - the event target to be watched * @param name - the name of the event to watch. E.g. "click" * @returns an Operation that yields the next emitted event * @since 3.0 */ export declare function once | (string & {})>(target: T, name: K): Operation>; /** * Create a {@link Stream} of events from any * [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget). * * See the guide on [Streams and Subscriptions](https://frontside.com/effection/docs/collections) * for details on how to use streams. * * @example * ```ts * import { each, on, once, spawn } from "effection"; * * // handle socket errors in a concurrent child task * yield* spawn(function* () { * throw yield* once(socket, "error"); * }); * * for (let event of yield* each(on(socket, "message"))) { * console.log(event.data); * yield* each.next(); * } * ``` * * @param target - the event target whose events will be streamed * @param name - the name of the event to stream. E.g. "click" * @returns a stream that will see one item for each event * @since 3.0 */ export declare function on | (string & {})>(target: T, name: K): Stream, never>; export {};