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

Support Set object in Vuex #1063

Closed
ppasieka opened this issue Nov 22, 2017 · 1 comment
Closed

Support Set object in Vuex #1063

ppasieka opened this issue Nov 22, 2017 · 1 comment

Comments

@ppasieka
Copy link

What problem does this feature solve?

Set object are very useful in situations where uniqueness is required. In my opinion it is cleaner to use Set instead object literals with values set to true

var state = {
  items: new Set()
}
var mutations = {
  newItem(state, item) {
    // state.items = { ...state.items, item: true }  // -- works but it is kinda hack
    // state.items = new Set([...state.items, item]) // -- this works correctly but is messy
    
    state.items.add(item) // -- it seems to not observe changes through add method.
  }
}

Link to sandbox with this example https://codesandbox.io/s/03w04xjq4p

What does the proposed API look like?

No extra API is needed. Observe changes through native Set methods add and delete

@ktsn
Copy link
Member

ktsn commented Nov 22, 2017

This is essentially duplicate of #439 and #471.
And there are nothing we can do for this in Vuex since it just use Vue's reactivity system.

@ktsn ktsn closed this as completed Nov 22, 2017
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