Answer the question
In order to leave comments, you need to log in
Why didn't the Subject event work?
Shipping:
private messageQueue = new AsyncSubject<IMessage>();
public publish(message: IMessage): void {
this.messageQueue.next(message);
}
public listen(): Observable<any> {
return this.messageQueue.asObservable();
}
constructor(private messageService: MessageService) {
this.messageService.listen().subscribe((message: IMessage) => {
console.log(message);
});
}
Answer the question
In order to leave comments, you need to log in
Because you took AsyncSubject
A variant of Subject that only emits a value when it completes.
this.messageQueue.complete()
listener listener in service constructor not possible?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question