Vuex: Vuex Store save function

Created on 27 Apr 2017  路  5Comments  路  Source: vuejs/vuex

What problem does this feature solve?

I have object events that I want to save to my Vuex Store, but when I saved to my Store instead show object data it's shows an empty

What does the proposed API look like?

It's save my object events function, so I can reuse my event via vue render createElement

Most helpful comment

State should be serializable. Functions should not save in the store. To reuse a function, simply export it somewhere then you can import and use it.

All 5 comments

If this is a feature request you may need to elaborate it more with your use case.
If it's an issue you must provide a minimal reproduction. I feel it looks more like a question, which you should ask on Stack Overflow with more details and your code.

I tried save my function into Vuex Store, but it fails.
I don't know if Vuex Store support function values inside an object or not.
If no, I want to make a feature request.

so, the question is.
Is Vuex Store support values as a function?

Please, make sure to read our Contributing Guide. Issues are for bug reports and feature requests only.

We encourage you to ask questions on the forum , Stack Overflow or on gitter and are happy to help you out there. Come back open a new issue if you find out there's a real issue.

State should be serializable. Functions should not save in the store. To reuse a function, simply export it somewhere then you can import and use it.

I have a similar use-case where specific functions are attached to specific objects-properties.
An object might look like this:

const a = {
  b: {
   name: 'b',
   click: function(){ // function specific to b}
  }
  c: {
   name: 'c',
   click: function(){ // function specific to c}
  }
}
Was this page helpful?
0 / 5 - 0 ratings