7
7
ResetOption ,
8
8
_DataSourceOptions ,
9
9
noop ,
10
+ _ResolveRejectFn ,
10
11
} from '../shared'
11
12
import { ref , Ref , unref } from 'vue-demi'
12
13
import type {
@@ -99,9 +100,9 @@ function updateDataFromDocumentSnapshot<T>(
99
100
path : string ,
100
101
snapshot : DocumentSnapshot < T > ,
101
102
subs : Record < string , FirestoreSubscription > ,
102
- ops : CommonBindOptionsParameter [ 'ops' ] ,
103
+ ops : OperationsType ,
103
104
depth : number ,
104
- resolve : CommonBindOptionsParameter [ 'resolve' ]
105
+ resolve : _ResolveRejectFn
105
106
) {
106
107
const [ data , refs ] = extractRefs (
107
108
// @ts -expect-error: FIXME: use better types
@@ -119,7 +120,7 @@ interface SubscribeToDocumentParameter {
119
120
path : string
120
121
depth : number
121
122
resolve : ( ) => void
122
- ops : CommonBindOptionsParameter [ 'ops' ]
123
+ ops : OperationsType
123
124
ref : DocumentReference
124
125
}
125
126
@@ -161,9 +162,9 @@ function subscribeToRefs(
161
162
path : string | number ,
162
163
subs : Record < string , FirestoreSubscription > ,
163
164
refs : Record < string , DocumentReference > ,
164
- ops : CommonBindOptionsParameter [ 'ops' ] ,
165
+ ops : OperationsType ,
165
166
depth : number ,
166
- resolve : CommonBindOptionsParameter [ 'resolve' ]
167
+ resolve : _ResolveRejectFn
167
168
) {
168
169
const refKeys = Object . keys ( refs )
169
170
const missingKeys = Object . keys ( subs ) . filter (
@@ -217,22 +218,12 @@ function subscribeToRefs(
217
218
} )
218
219
}
219
220
220
- interface CommonBindOptionsParameter {
221
- // vm: Record<string, any>
222
- target : Ref < unknown >
223
- // key: string
224
- // Override this property in necessary functions
225
- resolve : ( value : unknown ) => void
226
- reject : ( error : unknown ) => void
227
- ops : OperationsType
228
- }
229
-
230
221
export function bindCollection < T = unknown > (
231
222
target : Ref < unknown [ ] > ,
232
223
collection : CollectionReference < T > | Query < T > ,
233
- ops : CommonBindOptionsParameter [ 'ops' ] ,
234
- resolve : CommonBindOptionsParameter [ 'resolve' ] ,
235
- reject : CommonBindOptionsParameter [ 'reject' ] ,
224
+ ops : OperationsType ,
225
+ resolve : _ResolveRejectFn ,
226
+ reject : _ResolveRejectFn ,
236
227
extraOptions ?: FirestoreRefOptions
237
228
) {
238
229
// FIXME: can be removed now
@@ -367,10 +358,6 @@ export function bindCollection<T = unknown>(
367
358
}
368
359
}
369
360
370
- interface BindDocumentParameter extends CommonBindOptionsParameter {
371
- document : DocumentReference
372
- }
373
-
374
361
/**
375
362
* Binds a Document to a property of vm
376
363
* @param param0
@@ -379,9 +366,9 @@ interface BindDocumentParameter extends CommonBindOptionsParameter {
379
366
export function bindDocument < T > (
380
367
target : Ref < unknown > ,
381
368
document : DocumentReference < T > ,
382
- ops : BindDocumentParameter [ 'ops' ] ,
383
- resolve : BindDocumentParameter [ 'resolve' ] ,
384
- reject : BindDocumentParameter [ 'reject' ] ,
369
+ ops : OperationsType ,
370
+ resolve : _ResolveRejectFn ,
371
+ reject : _ResolveRejectFn ,
385
372
extraOptions ?: FirestoreRefOptions
386
373
) {
387
374
const options = Object . assign ( { } , DEFAULT_OPTIONS , extraOptions ) // fill default values
0 commit comments