import { Emitter } from './emitter.js' export type Subscriber = (emit: Emitter) => Unsubscriber export type Unsubscriber = | { unsubscribe(): void } | (() => any) | void export interface ISubscription { unsubscribe(): void readonly closed: boolean } export interface IObserver { start?(sub: ISubscription): any next?(val: T): any error?(err: Error): any complete?(val?: any): any } export interface IObservable { subscribe(observer: IObserver): ISubscription subscribe( next: (val: T) => any, error?: (err: Error) => void, complete?: (val: any) => void, ): ISubscription } export type IntoObservable = | IObservable | Promise | AsyncIterable | Iterable