The main changes is about how you import rxjs opreators from now on. And introduce lettable opreator.

import { range } from 'rxjs/observable/range';
import { map, filter, scan } from 'rxjs/operators'; const source$ = range(0, 10); source$.pipe(
filter(x => x % 2 === 0),
map(x => x + x),
scan((acc, x) => acc + x, 0)
)
.subscribe(x => console.log(x))

Build own opreator:

import { interval } from 'rxjs/observable/interval';
import { map, take, toArray } from 'rxjs/operators'; /**
* an operator that takes every Nth value
*/
const takeEveryNth = (n: number) => <T>(source: Observable<T>) =>
new Observable(observer => {
let count = 0;
return source.subscribe({
next(x) {
if (count++ % n === 0) observer.next(x);
},
error(err) { observer.error(err); },
complete() { observer.complete(); }
})
}); interval(1000).pipe(
takeEveryNth(2),
map(x => x + x),
takeEveryNth(3),
take(3),
toArray()
)
.subscribe(x => console.log(x));
// [0, 12, 24]

[RxJS] Learn How To Use RxJS 5.5 Beta 2的更多相关文章

  1. [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 ...

  2. [RxJS] Refactoring Composable Streams in RxJS, switchMap()

    Refactoring streams in RxJS is mostly moving pieces of smaller streams around. This lessons demonstr ...

  3. [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 ...

  4. [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 whe ...

  5. [rxjs] Creating An Observable with RxJS

    Create an observable var Observable = Rx.Observable; var source = Observable.create(function(observe ...

  6. [RxJS] Reactive Programming - What is RxJS?

    First thing need to understand is, Reactive programming is dealing with the event stream. Event stre ...

  7. [转]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 ...

  8. Angular Multiple HTTP Requests with RxJS

    原文:https://coryrylan.com/blog/angular-multiple-http-requests-with-rxjs ----------------------------- ...

  9. [RxJS] Introduction to RxJS Marble Testing

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

随机推荐

  1. avalon 作用域

    作用域绑定(ms-controller, ms-important) 如果一个页面非常复杂,就需要划分模块,每个模块交由不同的ViewModel去处理.我们就要用到ms-controller与ms-i ...

  2. 《Linux企业应用案例精解》一书已由清华大学出版社出版

    <Linux企业应用案例精解>简介 650) this.width=650;" border="0" alt="223754878.jpg" ...

  3. GridView单元格取值显示为&nbsp;

    在通过GridView取一个单元格(cell)的值时,数据库中为NULL,而页面上显示为空格.发现通过gridview.cell[i].text取出来的值为 ,导致获取数据出现问题. 解决方法: 一. ...

  4. lunix 安装使用mongo

    一.下载安装mongo版本客户端 1.进入mongo官网选择需要的版本号: https://www.mongodb.com/download-center/community(官网网址) 2.选择下载 ...

  5. 【TC SRM 718 DIV 2 A】RelativeHeights

    [Link]: [Description] 给你n个数字组成原数列; 然后,让你生成n个新的数列a 其中第i个数列ai为删掉原数列中第i个数字后剩余的数字组成的数列; 然后问你这n个数列组成的排序数组 ...

  6. hiho week 38 P1 : 二分·二分答案

    P1 : 二分·二分答案 Time Limit:10000ms Case Time Limit:1000ms Memory Limit:256MB 描述 在上一回和上上回里我们知道Nettle在玩&l ...

  7. Linux系统消息队列框架Kafka单机安装配置

    http://www.ithao123.cn/content-11128587.html

  8. 指尖上的电商---(10)SolrAdmin中加入多核

    在Solr中有的时候,我们并不仅仅是须要一种形式的索引文件.可能须要多种不同数据的索引文件.这时我们就能够在同一个Solr以下创建 多核. 比方,我们在solr以下想把产品信息和分类信息各存放一个索引 ...

  9. Supermap 组合单值专题图与标签专题图演示样例

    效果图例如以下:单值专题图并显示每一个区域的相关文字信息 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc29uZ2hmdQ==/font/5a6L5L2T ...

  10. 编译QCAD

    编译QCAD eryar@163.com 目前开源的二维CAD有QCAD.LibreCAD等,且LibreCAD可以说是QCAD的分支版本.对比这款开源软件,发现QCAD的功能与操作习惯和AutoCA ...