• [RxJS] Split an RxJS Observable into groups with groupBy


    groupBy() is another RxJS operator to create higher order observables. In this lesson we will learn how groupBy works for routing source values into different groups according to a calculated key.

    const numbersObservable = Rx.Observable.interval(500).take(5);
    
    numbersObservable
      .groupBy(x => x % 2)
      .map(innerObs => innerObs.count())
      .mergeAll()
      .subscribe(x => console.log(x));
    
    /*
    --0--1--2--3--4|
    
     groupBy(x => x % 2)
     
    --+--+---------|
        
        1-----3---|
      0-----2-----4|
      
     map(innerObs => innerObs.count())
     
    --+--+---------|
        
        ---------2|
      ------------3|
      
     mergeAll
     
    --------------(3,2)|
    
    */
  • 相关阅读:
    kafka+zookeeper集群部署
    rabbitmq集群部署
    nginx location语法
    rabbitmq单一部署
    Centos6国内可用yum源
    css
    imutable
    js解构复制语法
    redux
    json server问题
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6213448.html
Copyright © 2020-2023  润新知