Event Emitter
Let's add an event emitter in our application to update the navbar.
An Event Emitter allows us to emit custom events within our application. We can emit to components such as NavbarComponent
whenever a user has been logged in so that it can make event updates as needed, such as updating its template.
The login
method in AuthService
is one place where we’ll be emitting such an event, because it’s based on whether a user is logged in.
Below is our updated code. Use this to make further changes.
Get hands-on with 1400+ tech skills courses.