diff --git a/packages/mongo/observe_handle.ts b/packages/mongo/observe_handle.ts index d084322a61..66235fa920 100644 --- a/packages/mongo/observe_handle.ts +++ b/packages/mongo/observe_handle.ts @@ -4,12 +4,15 @@ let nextObserveHandleId = 1; export type ObserveHandleCallbackInternal = '_added' | '_addedBefore' | '_changed' | '_movedBefore' | '_removed'; + +export type Callback = (...args: T[]) => Promise | void; + /** * The "observe handle" returned from observeChanges. * Contains a reference to an ObserveMultiplexer. * Used to stop observation and clean up resources. */ -export class ObserveHandle { +export class ObserveHandle { _id: number; _multiplexer: ObserveMultiplexer; nonMutatingCallbacks: boolean; @@ -18,13 +21,13 @@ export class ObserveHandle { public initialAddsSentResolver: (value: void) => void = () => {}; public initialAddsSent: Promise - _added?: (...args: any[]) => Promise; - _addedBefore?: (...args: any[]) => Promise; - _changed?: (...args: any[]) => Promise; - _movedBefore?: (...args: any[]) => Promise; - _removed?: (...args: any[]) => Promise; + _added?: Callback; + _addedBefore?: Callback; + _changed?: Callback; + _movedBefore?: Callback; + _removed?: Callback; - constructor(multiplexer: any, callbacks: Record, nonMutatingCallbacks: boolean) { + constructor(multiplexer: any, callbacks: Record>, nonMutatingCallbacks: boolean) { this._multiplexer = multiplexer; multiplexer.callbackNames().forEach((name: ObserveHandleCallback) => {