3 years ago

State Management?

Posted 3 years ago by xdega

So I have been struggling to wrap my head around the following article: https://vuejs.org/guide/state-management.html#Simple-State-Management-from-Scratch

I wish to implement shared data between multiple components and this was the suggestion.

How would I implement this within the setup of Laravel 5?

For example, where do I put:

const sourceOfTruth = {}
const vmA = new Vue({
  data: sourceOfTruth
const vmB = new Vue({
  data: sourceOfTruth


var store = {
  debug: true,
  state: {
    message: 'Hello!'
  setMessageAction (newValue) {
    this.debug && console.log('setMessageAction triggered with', newValue)
    this.state.message = newValue
  clearMessageAction () {
    this.debug && console.log('clearMessageAction triggered')
    this.state.message = 'action B triggered'

Does anyone know of a working example of this that I could use for reference?

Thank You.

Please sign in or create an account to participate in this conversation.