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

Coffee-/ plain JavaScript? #20

Closed
dspangenberg opened this issue Dec 11, 2015 · 12 comments
Closed

Coffee-/ plain JavaScript? #20

dspangenberg opened this issue Dec 11, 2015 · 12 comments

Comments

@dspangenberg
Copy link

Could you please give an example in Coffeescript or plain JavaScript? Thanks!

@yyx990803
Copy link
Member

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.

@dspangenberg
Copy link
Author

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!

@skyrpex
Copy link

skyrpex commented Dec 12, 2015

You could transpile it using babel website in order to see the equivalent in ES5 (https://babeljs.io/repl/)

@dspangenberg
Copy link
Author

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.

@janwirth
Copy link

janwirth commented Jul 12, 2016

@dspangenberg do you have a public repository of vuex in coffeescript ?

@toast38coza
Copy link

In case it's useful, I've done the basic Counter example in old fashioned JavaScript:
https://gist.github.com/toast38coza/80bf55cda6ea6a05b6aeb0f12d558b74

@kticka
Copy link

kticka commented Oct 6, 2016

Does anyone knows how to implement namespacing for getters/actions in coffeescript?

@mshahbazi
Copy link

mshahbazi commented Apr 8, 2017

@kticka I have the same issue with coffeescript+vuex. wondering if you came up with a solution.

@LinusBorg
Copy link
Member

What exactly is the problem with namespaces and coffeescript?

@mshahbazi
Copy link

mshahbazi commented Apr 8, 2017

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".

@LinusBorg
Copy link
Member

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: jashkenas/coffeescript#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...
})

@mshahbazi
Copy link

Thank you @LinusBorg. It works. Just wondering if there is any cleaner way.

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

8 participants