Skip to content

Commit 807b4eb

Browse files
darrelfrancisposva
andauthored
docs: Enhance comments for reset option (#1342)
Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com>
1 parent 2bbf677 commit 807b4eb

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,28 +208,30 @@ this.$firestoreUnbind('documents')
208208
209209
</FirebaseExample>
210210
211-
By default, VueFire **will not reset** the property, you can customize this behavior by providing a second argument of options to the `firestoreUnbind`/`rtdbUnbind`
211+
By default, VueFire **does not reset** a bound property but you can customize this behavior by providing a second argument to the `firestoreUnbind`/`rtdbUnbind`
212212
213213
<FirebaseExample>
214214
215215
```js
216-
// default behavior
216+
// default behavior: leave the property unchanged after unbinding
217217
this.$databaseUnbind('user')
218218
// same as
219219
this.$databaseUnbind('user', false)
220-
// this.user === { name: 'Eduardo' }
220+
// Afterwards this.user will retain its value, e.g. { name: 'Eduardo' }
221221

222-
// using a boolean value for reset to keep current value
222+
// if you set the second parameter to `true`, the property will be reset to a standard value
223+
// for references bound as primitives or objects, this standard value is `null`
223224
this.$databaseUnbind('user', true)
224-
// this.user === null
225+
// Afterwards, this.user === null.
225226

226-
// using the function syntax to customize the value
227+
// for references bound as arrays, this standard value is an empty array
228+
this.$databaseUnbind('documents', true)
229+
// this.documents === []
230+
231+
// you can specify what value to reset the property to, using a function instead of `true`
227232
this.$databaseUnbind('user', () => ({ name: 'unregistered' }))
228233
// this.user === { name: 'unregistered' }
229234

230-
// for references bound as arrays, they are reset to an empty array by default instead of `null`
231-
this.$databaseUnbind('documents', true)
232-
// this.documents === []
233235
```
234236
235237
```js
@@ -253,23 +255,23 @@ this.$firestoreUnbind('documents', true)
253255
254256
</FirebaseExample>
255257
256-
It's also possible to customize this behavior when _binding_ by using the `reset` option:
258+
It's also possible to customize this behavior at the time of _binding_ by using the `reset` option:
257259
258260
<FirebaseExample>
259261
260262
```js
261263
// using a boolean value for reset
262264
await this.$databaseBind('user', userRef)
263265
this.$databaseBind('user', otherUserRef, { reset: true })
264-
// while the user is fetched
266+
// before the user has been fetched for the first time, you will have
265267
// this.user === null
266268
```
267269
268270
```js
269271
// using a boolean value for reset
270272
await this.$firestoreBind('user', userRef)
271273
this.$firestoreBind('user', otherUserRef, { reset: true })
272-
// while the user is fetched
274+
// before the user has been fetched for the first time, you will have
273275
// this.user === null
274276
```
275277

0 commit comments

Comments
 (0)