1👍
✅
Listening for an event in component
…inside your component definition:
created() {
EventBus.$on('UserLoggedOut', payload => { ...do what your need - "this" is current component...
});
}
For example, I want to modify the prop: authInfo with the newely gotten payload
This is little bit tricky. Props are considered "input only" in Vue. Common pattern is "props down, events up" – meaning parent component owns the data (in its own data()
), passes the data by props down to a child component and if the child component wants to change this data, it emits an event which parent listens to and in the handler change its internal data – new value will flow by reactivity and prop into the child.
Source:stackexchange.com