Skip to content

Commit 7531002

Browse files
committed
docs: global options
1 parent 6c3160f commit 7531002

File tree

4 files changed

+58
-4
lines changed

4 files changed

+58
-4
lines changed

docs/.vitepress/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ export default defineConfig({
155155
// text: 'Writing to the database',
156156
// link: '/guide/writing-data',
157157
// },
158+
{
159+
text: 'Global Options',
160+
link: '/guide/global-options',
161+
},
158162
],
159163
},
160164
{

docs/cookbook/migration-v2-v3.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ The `$rtdbBind` method is now called `$databaseBind` to have a consistent naming
9494

9595
Note that for compatibility reasons, the `$rtdbBind` and `$rtdbUnbind` methods are still available but marked as deprecated.
9696

97+
### Default changes to `reset` and `wait`
98+
99+
The default value of `reset` is now `false` and the default value of `wait` is now `true`. This should be seen as an enhancement as it makes it easier to load new _documents_ or _collections_ without affecting the view while data is being fetched for the first time from Firebase. If you wish the old behavior, you can enforce these settings globally:
100+
101+
```ts
102+
app.use(VueFire, {
103+
modules: [
104+
VueFireFirestoreOptionsAPI({
105+
// same behavior as vuefire v2
106+
reset: true,
107+
wait: false,
108+
}),
109+
VueFireDatabaseOptionsAPI({
110+
// same behavior as vuefire v2
111+
reset: true,
112+
wait: false,
113+
}),
114+
]
115+
})
116+
```
117+
97118
## Vuexfire
98119

99120
:::tip

docs/guide/global-options.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
# Global Options
1+
# Firestore and Database global Options
22

3-
You can modify the behavior of VueFire by modifying the global options:
3+
If you find yourself passing around the same options to `useDocument()`, `useObject()`, ..., you can use the global options to avoid repeating yourself:
44

5-
TODO:
5+
<FirestoreExample>
66

77
```ts
8-
import { globalFirestoreOptionss } from 'vuefire'
8+
import { globalDatabaseOptions } from 'vuefire'
9+
10+
globalDatabaseOptions.serialize = ...
11+
```
12+
13+
```ts
14+
import { globalFirestoreOptions } from 'vuefire'
915

1016
globalFirestoreOptions.converter = ...
1117
```
18+
19+
</FirestoreExample>
20+
21+
Changing these options will affect all calls to `useDocument()`, `useObject()`, ... in your application **and the Options API usage** as well (`$firestoreBind()`, `$rtdbBind()`).

docs/guide/options-api-realtime-data.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ app.use(VueFire, {
2828
})
2929
```
3030

31+
You can pass global options to the modules but note **these options are limited to the Options API usage**.They do not affect composition API calls such as `useDocument()` and `useObject()`. [Check the global options](./global-options.md) to see how you can override those.
32+
33+
```ts
34+
app.use(VueFire, {
35+
modules: [
36+
VueFireFirestoreOptionsAPI({
37+
// same behavior as vuefire v2
38+
reset: true,
39+
wait: false,
40+
}),
41+
VueFireDatabaseOptionsAPI({
42+
// same behavior as vuefire v2
43+
reset: true,
44+
wait: false,
45+
}),
46+
]
47+
})
48+
```
49+
3150
## Declarative binding
3251

3352
Any Database Reference provided in a `firebase`/`firestore` option will be bound at creation (after Vue's `beforeMount` hook) to the specified key on the component. In the following example we bind a Collection of Documents to our `documents` property. The key provided in the `firebase`/`firestore` option (`documents`) must be initialized in the `data` of the component:

0 commit comments

Comments
 (0)