Reputation: 79
I am emitting an event using an eventBus. I am looking to get the value from this on another component. At the moment, this triggers when something is selected, however, I want to be able to get the data from a Past event. For example, I have emitted the value when selecting an item. In another component, I wish to use this value again.
Here is the code to send the event:
clientId(client) {
eventBus.$emit("selected", client);
},
In the component, I am receiving it like this:
created() {
eventBus.$on("selected", index => this.client(index));
},
However it is not working for a past event.
I would like this to update a data value in a different component so that i can use the value.
How can I get the value of a past event?
Upvotes: 0
Views: 375
Reputation: 5048
You need a store for preserving data, simply inside your event bus update the store and then you can use a getter
to retrieve the data from the store in any component. If you are not familiar take a look at the vuex docs.
Upvotes: 2