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