Nov 1, 2016
4
Level 4
State Management?
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
})
and
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.
Level 4
3 likes
Please or to participate in this conversation.