From the course: Building Vue and Node Apps with Authentication

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Communicating between multiple components

Communicating between multiple components

From the course: Building Vue and Node Apps with Authentication

Start my 1-month free trial

Communicating between multiple components

- [Instructor] In this video, we will take a look at sending our new message once we submit it from our NewMessages component into our Messages component, so we can automatically display it. There's several ways to achieve this, the most complex being a three-component solution. So our parent component that contains both the NewMessage and Messages component So when a user types in a new message and hits Submit, the NewMessage component will emit an event that a new message was submitted. The parent component, in this case, the app component, will then react to that event and then tell our Messages component what the message was. A simpler solution is just to emit an event from our NewMessage component globally, which then our Messages component listens to directly, bypassing the parent component. So let's take a look at how to do that. So we'd like to emit a global event when we hit our Submit button. So below our axios.post call on line 32, let's add a new line. and we'll call the…

Contents