Within my messages.component.ts file, I have the following code snippet:
constructor(public messagesService: MessagesService) {
this.subscription = this.messagesService.getMessage().subscribe(message => { this.messages.push(message); });
this.subscription = this.messagesService.clearMessages().subscribe(this.messages = []);
}
The clearMessages method in my codebase looks like this:
clearMessages(): void {
this.subject.next();
}
I'm encountering an issue with combining this code with .subscribe(), as subscribe() is not recognized with type void. How can this be resolved?