I'm receiving a bunch of Messages from serverside and I wanna fake the typing by adding a interval to the pipe.
I'm doing this for now:
const stream = interval(1000)
.pipe(
map((): Message => {
return messages.pop();
})
);
this.feed = merge(
stream,
this.local
).pipe(
scan((acc, x) => [...acc, x], [])
);
But I want it to stop the interval once my array 'messages' is empty, could someone help me please? I have been trying to implement .TakeWhile with no success.
Thanks in advance.
takeWhile works fine, you'd need something like this:
I made a little example on stackblitz, I hope you can work this into your application: https://stackblitz.com/edit/typescript-sq6wxb?file=index.ts