[RxJS] Use groupBy in real RxJS applications
This lesson will show when to apply groupBy in the real world. This RxJS operator is best suited when a source observable represents many data sources, e.g. an observable for multitouch events.
const busObservable = Rx.Observable.of(
{code: 'en-us', value: '-TEST-'},
{code: 'en-us', value: 'hello'},
{code: 'es', value: '-TEST-'},
{code: 'en-us', value: 'amazing'},
{code: 'pt-br', value: '-TEST-'},
{code: 'pt-br', value: 'olá'},
{code: 'es', value: 'hola'},
{code: 'es', value: 'mundo'},
{code: 'en-us', value: 'world'},
{code: 'pt-br', value: 'mundo'},
{code: 'es', value: 'asombroso'},
{code: 'pt-br', value: 'maravilhoso'}
).concatMap(x => Rx.Observable.of(x).delay()); const all = busObservable
.groupBy(obj => obj.code) // 2-d obs
.mergeMap(innerObs => innerObs.skip().map(obj => obj.value)); all.subscribe(x => console.log(x));
/*
"hello"
"amazing"
"olá"
"hola"
"mundo"
"world"
"mundo"
"asombroso"
"maravilhoso"
*/
- The 'groupBy' return a 2-d observable, can use 'switchMap' or 'mergeMap' to conver to 1-d observable.
[RxJS] Use groupBy in real RxJS applications的更多相关文章
- [RxJS + AngularJS] Sync Requests with RxJS and Angular
When you implement a search bar, the user can make several different queries in a row. With a Promis ...
- [RxJS] Refactoring Composable Streams in RxJS, switchMap()
Refactoring streams in RxJS is mostly moving pieces of smaller streams around. This lessons demonstr ...
- [RxJS] Reactive Programming - Why choose RxJS?
RxJS is super when dealing with the dynamic value. Let's see an example which not using RxJS: var a ...
- [RxJS] Learn How To Use RxJS 5.5 Beta 2
The main changes is about how you import rxjs opreators from now on. And introduce lettable opreator ...
- [rxjs] Creating An Observable with RxJS
Create an observable var Observable = Rx.Observable; var source = Observable.create(function(observe ...
- [RxJS] Reactive Programming - What is RxJS?
First thing need to understand is, Reactive programming is dealing with the event stream. Event stre ...
- [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 ...
- [转]VS Code 扩展 Angular 6 Snippets - TypeScript, Html, Angular Material, ngRx, RxJS & Flex Layout
本文转自:https://marketplace.visualstudio.com/items?itemName=Mikael.Angular-BeastCode VSCode Angular Typ ...
- rxjs的世界
rxjs学习了几个月了,看了大量的东西,在理解Observable的本文借鉴的是渔夫的故事,原文,知识的主线以<深入浅出rxjs>为主,动图借鉴了rxjs中文社区翻译的文章和国外的一个动图 ...
随机推荐
- win7旗舰版怎么降级到专业版
一.操作准备及注意事项 1.UltraISO光盘制作工具9.5 2.备份C盘及桌面文件 二.win7旗舰版改成专业版的步骤 1.当前系统为Win7 SP1 64位旗舰版: 2.按Win+R打开运行,输 ...
- LiveReload配置,安装使用方法~~~前端页面神助手
一.Chrome端安装LiveReload插件 1.首先这里啰嗦一下,如果Chrome无法进入商店,可以先安装一下谷歌商店助手 谷歌商店插件地址 http://pan.baidu.com/s/1dF1 ...
- C语言库函数,头文件
参看:https://zhidao.baidu.com/question/328173842.html 该文件包含了的C语言标准库函数的定义 stdlib.h里面定义了五种类型.一些宏和通用工具函数. ...
- Tomcat源代码阅读#1:classloader初始化
Bootstrap 通过Tomcat的启动脚本能够看到启动的入口是在Bootstrap,来看下Bootstrap的main方法, /** * Main method and entry point w ...
- Stable Matching (Gale Sharpley Algorithm)
稳定婚配问题:n个男生n个女生.当中每一个人都有自己心仪的列表. 问怎样达成稳定的匹配(比方, b想B求婚,可是B已有的对象的优先级高于b,此时b的魅力不足以拆散B所处的那一对,即达到稳定状态.) ( ...
- iOS_04_数据类型、常量、变量
一.数据 1.什么是数据 * 生活中时时刻刻都在跟数据打交道,比如体重数据.血压数据.股价数据等.在我们使用计算机的过程中,会接触到各种各样的数据,有文档数据,图片数据,视频数据,还有聊天QQ产生的文 ...
- C语言深度解剖读书笔记
开始本节学习笔记之前,先说几句题外话.其实对于C语言深度解剖这本书来说,看完了有一段时间了,一直没有时间来写这篇博客.正巧还刚刚看完了国嵌唐老师的C语言视频,觉得两者是异曲同工,所以就把两者一起记录下 ...
- Redis学习笔记--Hash(五)
Redis的数据是通过key-value的方式存储的,对于value的数据类型有字符串.Hash.list.set.sortedSet在redis命令语句中,语句是忽略大小写的,但是key是不可以忽略 ...
- 10.11 android输入系统_补充知识_activity_window_decor_view关系
android里:1个application, 有1个或多个activity(比如支付宝有:首页.财富.口碑.朋友.我的,这些就是activity)1个activity, 有1个window(每个ac ...
- VS无法访问IIS元数据库 您没有足够的特权访问计算机上的IIS网站
进入windows\regedit.exe下的HKEY_CRRENT_USER\Software\Microsoft\Windows\CurrentVersion\Exploer\User Shell ...