|
1 | 1 | <script setup lang="ts">
|
2 |
| -import { doc } from 'firebase/firestore' |
| 2 | +import { doc, getDoc } from 'firebase/firestore' |
3 | 3 | import { useDocument } from 'vuefire'
|
4 | 4 | import { useFirestore } from '@/firebase'
|
| 5 | +import { ref } from 'vue' |
| 6 | +import { usePendingPromises } from '../../../src/ssr/plugin' |
5 | 7 |
|
6 | 8 | const db = useFirestore()
|
7 | 9 | const configRef = doc(db, 'configs', 'jORwjIykFo2NmkdzTkhU')
|
8 | 10 | // const itemRef = doc(db, 'tests', 'item')
|
| 11 | +const isDoneFetching = ref(false) |
| 12 | +const isAllDoneFetching = ref(false) |
9 | 13 |
|
10 |
| -const config = useDocument(configRef) |
| 14 | +getDoc(configRef).then((data) => { |
| 15 | + console.log('got data once', data) |
| 16 | +}) |
| 17 | +
|
| 18 | +const { data: config, promise } = useDocument(configRef, { wait: true }) |
11 | 19 | // const { data: hey } = useDocument(configRef)
|
| 20 | +
|
| 21 | +promise.value.then((data) => { |
| 22 | + console.log('one', data) |
| 23 | + isDoneFetching.value = true |
| 24 | +}) |
| 25 | +
|
| 26 | +usePendingPromises().then((data) => { |
| 27 | + console.log(data) |
| 28 | + isAllDoneFetching.value = true |
| 29 | +}) |
12 | 30 | </script>
|
13 | 31 |
|
14 | 32 | <template>
|
15 | 33 | <p>config:</p>
|
| 34 | + <p>finished: {{ isDoneFetching }}</p> |
| 35 | + <p>All finished: {{ isAllDoneFetching }}</p> |
16 | 36 | <pre>{{ config }}</pre>
|
17 | 37 | </template>
|
0 commit comments