import { ChangeStream, ChangeStreamOptions, Collection, Document, Filter } from 'mongodb'; import { ErrorEvents } from './ErrorEvents'; import { PromiseTracker } from './PromiseTracker'; import { Subscription, SubscriptionCallback, SubscriptionOptions } from './Subscription'; import { TypedEventEmitter } from './TypedEventEmitter'; export interface SubscriberOptions { /** Global MongoDB filter to apply on change stream. */ filter?: Filter; changeStreamOptions?: ChangeStreamOptions; } export type SubscriberEvents = ErrorEvents; export declare class Subscriber extends TypedEventEmitter> { protected collection: Collection; protected filter: Filter; protected changeStreamOptions: ChangeStreamOptions; protected subscriptions: Set>; protected changeStream?: ChangeStream; protected promises: PromiseTracker; protected closed: boolean; constructor(collection: Collection, options?: SubscriberOptions); /** * Subscribes to matching messages in the future. * * - All active subscribers will receive all future matching messages. * - Events are delivered at most once. * - Events are delivered in database insertion order. * - Past messages are ignored. * - Each `Subscriber` instance creates one MongoDB change stream. * - Change streams occupy one connection, * - so you'll usually want only one `Subscriber` instance, * - and multiple `.subscribe()` calls with local filters. */ subscribe(callback: SubscriptionCallback, options?: SubscriptionOptions): Subscription; close(): Promise; protected init(): void; }