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)| */

[RxJS] Split an RxJS Observable into groups with groupBy的更多相关文章

  1. [RxJS] Split an RxJS observable conditionally with windowToggle

    There are variants of the window operator that allow you to split RxJS observables in different ways ...

  2. [RxJS] Split an RxJS observable with window

    Mapping the values of an observable to many inner observables is not the only way to create a higher ...

  3. [RxJS] Stopping a shared observable execution

    ConnectableObservable has the connect() method to conveniently dictate the start of the shared execu ...

  4. [RxJS] Introduction to RxJS Marble Testing

    Marble testing is an expressive way to test observables by utilizing marble diagrams. This lesson wi ...

  5. [AngularJS + RxJS] Search with RxJS

    When doing search function, you always need to consider about the concurrent requests. AEvent ----(6 ...

  6. Angular快速学习笔记(4) -- Observable与RxJS

    介绍RxJS前,先介绍Observable 可观察对象(Observable) 可观察对象支持在应用中的发布者和订阅者之间传递消息. 可观察对象可以发送多个任意类型的值 -- 字面量.消息.事件. 基 ...

  7. RxJS——可观察的对象(Observable)

    可观察的(Observable) 可观察集合(Observables)是多值懒推送集合.它们填补了下面表格的空白: SINGLE MULTIPLE Pull Function Iterator Pus ...

  8. RxJS + Redux + React = Amazing!(译二)

    今天,我将Youtube上的<RxJS + Redux + React = Amazing!>的后半部分翻译(+机译)了下来,以供国内的同学学习,英文听力好的同学可以直接看原版视频: ht ...

  9. [RxJS] Stream Processing With RxJS vs Array Higher-Order Functions

    Higher order Array functions such as filter, map and reduce are great for functional programming, bu ...

随机推荐

  1. sql server存储过程调用C#编写的DLL文件

    新建C#类库,编译. 引用 using Microsoft.SqlServer.Server; 方法 [SqlFunction]public static int GenerateTxt(){ ... ...

  2. 1.24 Python知识进阶 - 类与对象

    类 语法格式: class Dog(object): print("the dog is barking ...") Dog为类名,object为要继承的基类,Dog类会从基类ob ...

  3. Navicat for MySQL 新建查询时,报can't create file ...系统找不到指定的文件夹出现问题

    如图点击新建查询报错 解决办法 将这个路径修改一下就ok了

  4. 今天看到可以用sqlalchemy在python上访问Mysql

    from sqlalchemy import create_engine, MetaData, and_ 具体的还没有多看.

  5. Codeforces Round #277.5 解题报告

    又熬夜刷了cf,今天比正常多一题.比赛还没完但我知道F过不了了,一个半小时贡献给F还是没过--应该也没人Hack.写写解题报告吧= =. 解题报告例如以下: A题:选择排序直接搞,由于不要求最优交换次 ...

  6. HDU 5389 Zero Escape (MUT#8 dp优化)

    [题目链接]:pid=5389">click here~~ [题目大意]: 题意: 给出n个人的id,有两个门,每一个门有一个标号,我们记作a和b,如今我们要将n个人分成两组,进入两个 ...

  7. Android RingtoneManager 铃声管理

    package com.Aina.Android; import java.io.File; import android.app.Activity; import android.content.I ...

  8. WEB前端--深入进去

    在网站开发这条道路上做专做精,一个专题一个专题的深入探索,一个盲区一个盲区的理解和记忆,终有大成的那一天的.

  9. 关于React中,map出来的元素添加事件问题

    用es6 map 的写法 直接绑定一个onTouchStart 事件不会报错. 用es5的map写法  如果不加上this  会报这个错误 无法读取未定义的属性 解决的方法是 绑定this  就可以了

  10. 15、python学习手册之:元组、文件及其他

    1.使用文本来存储python对象时,必须使用转换工具把对象转成字符串 2.内置函数eval可以把字符串当做可执行程序代码:eg  s = ‘[1,2,3]’    eval(s) -->[1, ...