I m using ng2-cable for chat and broadcast any action from server in rails
AngularJs
--> In app.component.ts
import { Ng2Cable, Broadcaster } from 'ng2-cable';
--> used this for connection
private ng2cable: Ng2Cable,
this.ng2cable.subscribe(environment.apiEndpoint+"/cable", 'ChatChannel',{room: this.currentUser.id});
--> Read notification from server
import { Broadcaster } from 'ng2-cable';
private broadcaster: Broadcaster,
this.broadcaster.on('ExpertQuestionList').subscribe(message => { console.log("This called multiple time when you come back to this page after once load") } );
Here, ExpertQuestionList is one action name. It will broadcast from rails server using action cable.
------------------------------------------------------------------------------------------------------------------------
ExpertQuestionList broadcast one time from server, i can see that in my rails log but called twice in console.log. Twice means it repeat multiple time same as how many time you will come on this page. so simple in reinitialise many time. I want something like reset or destroy actions (this.broadcaster.on('ExpertQuestionList'))