Skip to content

Commit 740b75f

Browse files
committed
docs: wip external like pinia
1 parent 18224e4 commit 740b75f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/guide/subscriptions-external.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Binding Firebase Reference to existing Vue Refs
2+
3+
When you need to bind a Firebase reference to existing Vue `ref()`, you can pass it as the `target` option:
4+
5+
```ts
6+
todos // Ref<Todo[]>
7+
useCollection(todoListRef, { target: todos })
8+
```
9+
10+
## Pinia
11+
12+
If you are using [Pinia](https://pinia.vuejs.org), you can directly use the `useCollection` function within [setup stores](https://pinia.vuejs.org/cookbook/composables.html#setup-stores):
13+
14+
```ts
15+
import { defineStore } from 'pinia'
16+
17+
export const useTodoStore = defineStore('todos', () => {
18+
const todos = useCollection(todoListRef)
19+
20+
return { todos }
21+
})
22+
```
23+
24+
Note you will still have to follow the [Firebase API](https://firebase.google.com/docs/firestore/manage-data/structure-data) (e.g. `addDoc()`, `updateDoc()`, etc) to update the data.
25+
26+
## TypeScript
27+
28+
TODO: use type helper to add properties of converter

0 commit comments

Comments
 (0)