How can I update Observable, which used in async pipe?

Viewed 2332

Problem is that: I have simple component, which renders some "history" of messages. When app is loaded, it makes POST-request, gets data and sets data to Observable like this

this.messages$ = Observable.of(messagesAfterPOSTRequest);

where public messages$: Observable<any>;

This data is rendered in template via async pipe:

let message of messages$ | async

It works good, but ....

I get some "new messages" via websocket, so I would like to update the list, which was created on previous step. I am trying to use scan()

this.messages$ = this.messages$.scan((accMessage, numMessage) => {
        console.log("inside current mesages", accMessage, numMessage)
      });

In order to "update" current list messages, but this console.logs looks like never work, even with subscribe()

1 Answers
Related