diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d69b0..4b8bd54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## v1.5.0 19-July-2022 - rename setting `allFieldsPossiblyUndefined` as `allFieldsPossiblyReadAsUndefined` +- remove onSnapshot onCompletion parameter ## v1.3.0 6-May-2022 diff --git a/package-lock.json b/package-lock.json index caced0d..5efa672 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "firelordjs", - "version": "1.4.4", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "firelordjs", - "version": "1.4.4", + "version": "1.5.0", "license": "MIT", "devDependencies": { "@babel/preset-env": "^7.17.10", diff --git a/package.json b/package.json index 9010bc0..c133365 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "test": "firebase emulators:exec --only firestore \"rm -rf coverage && jest --forceExit\"", "parcel": "npm un firebase && npm i firebase && rm -rf dist && tsc --emitDeclarationOnly true && parcel build && npm i -D firebase", "build": "rm -rf dist && tsc", - "link": "npm link && npm link firelordjs", + "link": "npm unlink firelordjs && npm link && npm link firelordjs", "dev": "---------------------dev------------------------", "d-link": "npm run build && npm run link", "d-test": "tsc && npm test", diff --git a/src/onSnapshot/onSnapshot.test.ts b/src/onSnapshot/onSnapshot.test.ts index 4c2aa1b..0cdc253 100644 --- a/src/onSnapshot/onSnapshot.test.ts +++ b/src/onSnapshot/onSnapshot.test.ts @@ -59,9 +59,6 @@ describe('test onSnapshot', () => { unsub() done() }, - () => { - // - }, () => { // } diff --git a/src/onSnapshot/onSnapshot.ts b/src/onSnapshot/onSnapshot.ts index d09e517..70acd22 100644 --- a/src/onSnapshot/onSnapshot.ts +++ b/src/onSnapshot/onSnapshot.ts @@ -27,64 +27,27 @@ export const isOptions = ( export const onSnapshot: OnSnapshot = ( reference, onNext, - onError, - onCompletion?: (() => void) | OriSnapshotListenOptions, + onError?: ((error: FirestoreError) => void) | OriSnapshotListenOptions, options?: OriSnapshotListenOptions ) => { const newOnError = isOptions(onError) ? undefined : onError - const newOnCompletion = isOptions(onCompletion) ? undefined : onCompletion - const newOptions = - options || - (isOptions(onError) ? onError : undefined) || - (isOptions(onCompletion) ? onCompletion : undefined) + const newOptions = options || (isOptions(onError) ? onError : undefined) return newOptions ? onSnapshot_(reference as OriQuery, newOptions, { // @ts-expect-error next: onNext, error: newOnError, - complete: newOnCompletion, }) : onSnapshot_( reference as OriQuery, // @ts-expect-error onNext, - newOnError, - newOnCompletion + newOnError ) } type OnSnapshot = { - /** - * Attaches a listener for `DocumentSnapshot` events. You may either pass - * individual `onNext` and `onError` callbacks or pass a single observer - * object with `next` and `error` callbacks. - * - * NOTE: Although an `onCompletion` callback can be provided, it will - * never be called because the snapshot stream is never-ending. - * - * @param reference - A reference to the document to listen to. - * @param onNext - A callback to be called every time a new `DocumentSnapshot` - * is available. - * @param onError - An optional callback to be called if the listen fails or is - * cancelled. No further callbacks will occur. - * @param onCompletion - optional callback, but will not be called since streams are - * never ending. - * @param options - Options controlling the listen behavior. - * @returns An unsubscribe function that can be called to cancel - * the snapshot listener. - */ - | DocumentReference>( - reference: Ref extends never ? Ref : Query | DocumentReference, - onNext: ( - snapshot: Ref extends DocumentReference - ? DocumentSnapshot - : QuerySnapshot - ) => void, - onError?: (error: FirestoreError) => void, - onCompletion?: () => void, - options?: SnapshotListenOptions - ): Unsubscribe /** * Attaches a listener for `DocumentSnapshot` events. You may either pass * individual `onNext` and `onError` callbacks or pass a single observer