Hacker News new | ask | show | jobs
by pmontra 971 days ago
I have a customer that uses Vue. It's much easier than React but still not easy enough. The complication as usual is the state management. There are prop local to a component and a global state. Computed values and "real" values. There are different ways to update those values some as easy as to assign to this.property and some complicated calls to functions somewhere else. Again, compared to React there is less time lost in boilerplate and puzzles, but it's still too much given that often all I want to do is equivalent to

  this.parent.aList.push(item) 
or

  globalState.customersList.push(item)
Ideally I'd write it in JavaScript instead of using an API. I would accept

  globalState(customerList, "push", item)
if calling a function of the library is the only way to trigger the UI update code.

Edit. I add an extra nuisance that could be solved by a better and more straightforward syntax

I have to work with code like this

  store.js:
  import * as model from './modules/model'

  component.vue:
  import { mapState } from 'vuex'
  computed: {
    ...mapState('model', ['model']),
  }
  this.$store.dispatch('model/method', {...})
which calls "method" defined in "model" and which is very convoluted compared to what we are used to in other languages

  import Model from `store/model`
  Model.update(args)
If often think that framework and library authors don't try hard enough to build tools with simple interfaces. That reminds me about Erlang/Elixir handle_call/handle_cast.