You can create a subject inside your service
messageSource: Subject<string>;
and instantiate inside your constructor
this.messageSource = new Subject<string>();
in your component you can do this,
this.yourService.messageSource.next('whatvermessage');
and if you want to subscribe to it, you can do
this.yourService.messageSource.asObservable().subscribe((value: string) => {
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…