Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instanceDefaults as an object can cause complications #224

Closed
midzdotdev opened this issue May 13, 2019 · 3 comments
Closed

instanceDefaults as an object can cause complications #224

midzdotdev opened this issue May 13, 2019 · 3 comments

Comments

@midzdotdev
Copy link
Contributor

Neither a bug or a feature request

I'm posting this for myself to come back to at a later time unless someone else wants to do it.

The issue is with instanceDefaults as an object where it maintains the contents of any array or object properties between model instances. The workaround for this is to make instanceDefaults a function that returns the same object.

It took me a little while to figure out why this was happening and so I felt this should be more clear in the docs, especially for the less versed coders out there.

@midzdotdev
Copy link
Contributor Author

The code below will have arr maintain its value between instances when doing new this.$FeathersVuex.Model().

instanceDefaults: {
  arr: []
}

The workaround is to do this:

instanceDefaults: () => ({
  arr: []
})

@marshallswain
Copy link
Member

@james2mid thanks for making this more visible. Version 2.x will only allow the function version. I'm going to close this after it is released.

@midzdotdev
Copy link
Contributor Author

See the PR above

marshallswain added a commit that referenced this issue Jun 10, 2019
Warn against instanceDefaults as an object #224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants