The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Displaying Initial Data with StartWith

Displaying Initial Data with StartWith

1:06
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
Noah Rawlins

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 to get around this, but that seems wrong.

Is there someway to put in the signature of scan that it converts this Observable 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

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?