June 2018
Intermediate to advanced
348 pages
8h 19m
English
If we published an event at the first method, now it's time to listen to it. The first parameter is the event name we want to subscribe, and the second is a callback function that can be used to get the value sent by the event publisher. This data can be a simple string, or, like in our case, an object.
Like the preceding example, we can access this method through our EventAggregator class instance in our component:
let subscription = this.ea.subscribe('dataRetrievingEvent', response => {
console.log(response);
// This should yield: Object {message: "Loading...don't close the window!"}
});
We have defined a subscriber object which is basically a method call. This object will make a direct reference to the ...
Read now
Unlock full access