Displaying Initial Data with StartWith

John Lindquist
InstructorJohn Lindquist

Share this video with your friends

Send Tweet

You often need to render out data before you stream begins from a click or another user interaction. This lessons shows how to use startWith to set the initial output before you trigger your stream.

Noah Rawlins
Noah Rawlins
~ 5 years ago

In my typescript compiler it complains that I am passing an object, {count: 0} to startsWith() for an interval observable that emits numbers.

I can explicitly type the interval$ as Observable<any> to get around this, but that seems wrong.

Is there someway to put in the signature of scan that it converts this Observable<number> to Observable<{count: number}> so the startsWith({count: 0}) doesn't generate an error?

This is with typescript 1.8.10 and rxjs 5.0.0 beta 7

ganqqwerty
ganqqwerty
~ 3 years ago

great lecture, thanks!