Could you please give an example in Coffeescript or plain JavaScript? Thanks!
It is plain JavaScript, just using the latest syntax. It would probably take less time for you to just search for a quick ES2015 tutorial/video than for me to rewrite the examples.
With plain JS I've meant something without the ES6 stuff (imports etc.). But it was not intended to steal your rare time. I've searched and traid for hours without success, otherwise I havn't asked here. Sorry for bothering you!
You could transpile it using babel website in order to see the equivalent in ES5 (https://babeljs.io/repl/)
Thanks for the advice. But I've tried it yesterday and the transpiled code is a mess. Finally I got Vuex running in coffeescript. Only the store/index.js from the cart example is still JS.
@dspangenberg do you have a public repository of vuex in coffeescript ?
In case it's useful, I've done the basic Counter example in old fashioned JavaScript:
https://gist.github.com/toast38coza/80bf55cda6ea6a05b6aeb0f12d558b74
Does anyone knows how to implement namespacing for getters/actions in coffeescript?
@kticka I have the same issue with coffeescript+vuex. wondering if you came up with a solution.
What exactly is the problem with namespaces and coffeescript?
in computed section, I cannot map more than once (i.e. the mapGetters is not compiled). See this:
computed:
Vuex.mapState 'ns1', ['data1'],
Vuex.mapGetters 'ns2', ['data2']
Actually I cannot say it is a namespace issue, since putting data1 and data2 in root does not work as well:
computed:
Vuex.mapState ['data1'],
Vuex.mapGetters ['data2']
I came up with "the splats syntax is not mature in coffeescript yet".
Oh, so the problem is that coffeecript doesn't support/ have a object rest spread operator.
Seems there's a PR open for this, but not merged: https://github.com/jashkenas/coffeescript/pull/4473
You will have to use an equivalent of Object.assign() (no idea how to write that in CS):
computed: Object.assign(
Vuex.mapState ['data1', 'data2'],
{
// normal computed props go here...
})
Thank you @LinusBorg. It works. Just wondering if there is any cleaner way.
Most helpful comment
Oh, so the problem is that coffeecript doesn't support/ have a object rest spread operator.
Seems there's a PR open for this, but not merged: https://github.com/jashkenas/coffeescript/pull/4473
You will have to use an equivalent of Object.assign() (no idea how to write that in CS):