Skip to content

Commit 6422c10

Browse files
Merge pull request #227 from james2mid/patch-1
Warn against instanceDefaults as an object #224
2 parents f56c00d + 0f9276b commit 6422c10

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/model-classes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ export default new Vuex.Store({
138138

139139
With the above configuration, when you create a [`Todo` instance](./model-classes.md), it will have the attributes provided as `instanceDefaults`. This is especially useful for binding to form data. If the attributes aren't defined while binding, the automatic Vue reactivity won't work. Remember to not set any of the attributes to `undefined`, but instead use `null`. If not, the reactivity breaks, and you might spend some time wondering why your form is broken.
140140

141+
### A Word Of Warning
142+
143+
One thing to be aware of when using `instanceDefaults` as an object is that values can persist between instances and mutate separate instances. For example, when including an `Array`, changes made to one instance will affect any other instances of this model too.
144+
145+
Using `instanceDefaults` as an object will be deprecated in the next major version of `feathers-vuex` so it's best to stick to the function option below.
146+
141147
## instanceDefaults | Function <Badge text="1.7.0+" /> <Badge text="recommended" type="warn"/>
142148

143149
A much more powerful API is available when you provide `instanceDefaults` as a function. The function will be called with the following arguments and should return an instanceDefaults object.

0 commit comments

Comments
 (0)