import { PureEvent, PureEventDelegate, type PureEventListenOptions } from "@gaubee/util";
/**
 * 个极简的事件监听, 支持异步错误捕捉
 * 对流有着极好的支持，支持背压，因此你甚至可以把它当作一个流发射器
 *
 * @example
 * ```ts
 * const flow = new SharedFlow<number>();
 *
 * const off = flow.on((data) => {
 *      console.log('on data', data)
 * })
 *
 * async function once() {
 *      flow.once((data) => {
 *           console.log('once data', data)
 *      })
 *      console.log('await once data', await flow.once())
 * }
 *
 * async function emit() {
 *     for (let i = 0; i < 10; i++) {
 *         await flow.emit(i);
 *     }
 * }
 *
 * async function stream() {
 *     for await (const data of flow) {
 *         await delay(1000);
 *         console.log('for await', data);
 *     }
 * }
 * ```
 */
export declare class SharedFlow<T> extends PureEventDelegate<T> implements AsyncIterable<T> {
    #private;
    constructor(by?: PureEvent<T>);
    /**
     * 将事件以流的方式发出
     * 和使用 `for await (const data of flow)` 的方式来隐性触发流监听不同，这里的 stream 函数在调用的时候，就会立刻进行数据监听，因此可以避免一些执行顺序的误会
     */
    stream(options?: PureEventListenOptions): AsyncGenerator<Awaited<T>, void, unknown>;
    [Symbol.asyncIterator](): AsyncGenerator<Awaited<T>, void, unknown>;
}
export declare const sharedFlow: <T>(by?: any) => SharedFlow<T>;
//# sourceMappingURL=shared_flow.d.ts.map