All of the combination operators take, or more observables as input. These operators may also is alternatively called "vertical combination operators", because of how they work in a marble di Agram. Next, we'll learn about scan (), which are an important "horizontal combination operator".
varclick$ = Rx.Observable.fromEvent (Document.queryselector ("#btn"), ' click ');/*----EV-----EV---EV----EV----EV----.. Mapto (1)----1-----1---1----1----1-----.. Scan (ACC, Curr) = acc + curr, 0)----1------2----3-----4-----5-----..*/varclicks$ =Click$.mapto (1). Scan (ACC, Curr)= { returnACC +Curr},0);varSub =Clicks$.subscribe ((x)= = Console.debug ("Total Clicks:" +x), (ERR)=Console.error (Err), ()= = Console.info ("Done"))
varfoo$ = Rx.Observable.of (' h ', ' e ', ' l ', ' l ', ' O '). zip (Rx.Observable.interval ((c, t) = =c);varbar$ = Foo$.scan (ACC, Curr) = { returnACC +Curr;},‘‘);/*-----H-----E-----L-----L------o| (foo) scan ((ACC, Curr) = acc + curr, ')-----h-----(He)-(HEL)-(Hell)-(hello|) (bar)*/varSub =Bar$.subscribe ((x)=console.debug (x), (ERR)=Console.error (Err), ()= = Console.info ("Done"));/** "H" "he" "Hel" "Hell" "Hello" "Done"*/
[RxJS] Transformation Operator:scan