@@ -281,14 +281,17 @@ export function bindCollection<T = unknown>(
281281 reject : _ResolveRejectFn ,
282282 extraOptions ?: FirestoreRefOptions
283283) {
284- // FIXME: can be removed now
285284 const options = Object . assign ( { } , DEFAULT_OPTIONS , extraOptions ) // fill default values
286285
287- const { snapshotListenOptions, snapshotOptions, wait } = options
286+ const { snapshotListenOptions, snapshotOptions, wait, once } = options
288287
288+ // TODO: remove ops
289289 const key = 'value'
290+ // with wait we delay changes to the target until all values are resolved
291+ // let arrayRef = wait ? ref([]) : target
292+ // FIXME:
293+ let arrayRef = ref ( wait ? [ ] : target . value )
290294 if ( ! wait ) ops . set ( target , key , [ ] )
291- let arrayRef = ref ( wait ? [ ] : target [ key ] )
292295 const originalResolve = resolve
293296 let isResolved : boolean
294297 let stopOnSnapshot = noop
@@ -378,10 +381,10 @@ export function bindCollection<T = unknown>(
378381 if ( data && ( data as any ) . id in validDocs ) {
379382 if ( ++ count >= expectedItems ) {
380383 // if wait is true, finally set the array
381- if ( options . wait ) {
384+ if ( wait ) {
382385 ops . set ( target , key , unref ( arrayRef ) )
383- // use the proxy object
384- // arrayRef = target.value
386+ // FIXME: use the proxy object
387+ // arrayRef = target
385388 }
386389 originalResolve ( unref ( arrayRef ) )
387390 // reset resolve to noop
@@ -400,18 +403,19 @@ export function bindCollection<T = unknown>(
400403 // since this can only happen once, there is no need to guard against it
401404 // being called multiple times
402405 if ( ! docChanges . length ) {
403- if ( options . wait ) {
406+ if ( wait ) {
404407 ops . set ( target , key , unref ( arrayRef ) )
405- // use the proxy object
408+ // FIXME: use the proxy object
406409 // arrayRef = target.value
407410 }
408411 resolve ( unref ( arrayRef ) )
409412 }
410413 }
411414
412- if ( options . once ) {
415+ if ( once ) {
413416 getDocs ( collection ) . then ( onSnapshotCallback ) . catch ( reject )
414417 } else {
418+ // we need a way to detect when the data is fully loaded
415419 stopOnSnapshot = onSnapshot ( collection , onSnapshotCallback , reject )
416420 }
417421
0 commit comments