I have 2 components namely A and B. The component A catches a event when some some event is fired. I mean to say it shows some message as "Job 1 is Running". So here whatever the message the comonent A is showing the same message i have to show it on the component B. For that i have written the code something like this: Here in when i click the event run button it will check the entry.status == 'In_progress', if this condition matches then in the component A i will get the message as "Job 1 is running" something like. I want to catch the same message in component B also. For that i have added some code see below:
componentA.component.ts
tasks(){
this.tasksRes = results['data'];
this.count = 0;
for (let entry of this.tasksRes) {
if (entry.status == 'In_progress') {
this.count = this.count + 1;
}
}
}
connect(){
let source = new EventSource('/api/v1/events/register');
source.addEventListener('message', message => {
this.tasks();
});
}
componentA.component.html
<ul class="p-0" *ngFor="let task of tasksRes">
<li>
<span class="text-muted">{{task.eventType}}</span>
</li>
<ul>
The above code shows the message as "Job 1 running".
I am trying to get the "task.eventType" in component B also. so how can we achieve it. How can i get the same status here in component B also. Help is highly appreciated.
Thanks