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. PowerShell中和服务相关的命令

    New-Service https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/new-s ...

  2. 2015北京网络赛 J Scores bitset+分块

    2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...

  3. MVC页面常用方法

    转自:https://www.cnblogs.com/baisoft/p/5839319.html @RenderBody 在Razor引擎中没有了“母版页”,取而代之的是叫做“布局”的页面(_Lay ...

  4. python获取教务管理系统的MM照片

    前提:你的教务管理系统是明文存储大家的图片,加密的图片就不好弄了... 也就是能够通过浏览器直接访问...技术上就不存在什么问题了...如果是学号存储的就更方便了 然后我们就可以写个小脚本了...其实 ...

  5. 实现人脸识别性别之路---网页上的video标签

    <video> 元素支持三种视频格式: MP4, WebM, 和 Ogg.但是,不同的浏览器对视频格式的支持也不一致,因此为了让浏览器都适应,我们使用source属性来对视频文件格式定义 ...

  6. 封装TensorFlow神经网络

    为了参加今年的软件杯设计大赛,这几个月学习了很多新知识.现在大赛的第二轮作品优化已经提交,开始对这四个月所学知识做一些总结与记录. 用TensorFlow搭建神经网络.TensorFlow将神经网络的 ...

  7. 【Codeforces Round #459 (Div. 2) B】 Radio Station

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map模拟一下映射就好了. [代码] #include <bits/stdc++.h> using namespace ...

  8. css3中关于伪类的使用

    目标: css中after伪类,last-child伪类的使用.以及部分css3的属性. 过程: 在制作导航时.常常会遇到在每个li后面加入一个切割符号,到最后一个元素的时候,切割符就会去掉的一种效果 ...

  9. python Tricks —— list 镜像复制与 list comprehension 列表解析的顺序

    0. 对 list 镜像复制,a = [1, 2, 3] ⇒ [1, 2, 3, 3, 2, 1] a*2 ⇒ a = [1, 2, 3, 1, 2, 3] a.extend(reversed(a)) ...

  10. vs2010 Visula C++ 把CString 转换为string 类型

    CString strSomeCstring ("This is a CString Object"); // Use ANSI variant CStringA to conve ...