Combine Values of One Observable with RxJS scan

InstructorAndré Staltz

Share this video with your friends

Send Tweet

All of the combination operators take two or more observables as input. These operators may also be alternatively called "vertical combination operators", because of how they work in a marble diagram. Next, we will learn about scan(), which is an important "horizontal combination operator".

🚨 Since we are importing interval from RxJS, we don't need to preface our Observables with Rx.Observable. You can no longer .{operator}, you need to .pipe({operator}) instead. To link together multiple Observables and Operators, the method is a bit different. You call zip first, then list your Observables, your functions, then pipe your Operators.

Steve Lee
~ 8 years ago

Rather than (hel) - 3 separate characters - shouldn't the result be 'hel' - a string. I was thinking acc+x will be string catenation given the seed is a the empty string. Am I missing something?

André Staltzinstructor
~ 8 years ago

Hi Steve. We took some freedom to write it more concisely. The precisely correct way of writing it would be ('hel'), but it would take too much space in the diagram.