一起来看 rxjs
更新日志2018-05-26 校正2016-12-03 第一版翻译过去你错过的 Reactive Programming 的简介你好奇于这名为Reactive Programming(反应式编程)的新事物, 更确切地说,你想了解它各种不同的实现(比如 [Rx*], [Bacon.js], RAC 以...
[Angular 2] Managing State in RxJS with StartWith and Scan
The scan operator in RxJS is the main key to managing values and states in your stream. Scan behaves just as a reduce function would, but scan is able...
[RxJS] map vs flatMap
What's the difference between map and flatmap? First, let's show what map is. To show that, I need a source stream, so I'm going to make an interval. ...
RxJS:从Observable.fromPromise拆分数组结果
I'm using RxJS here and I can't seem to get over this seemingly simple issue. 我在这里使用RxJS,我似乎无法克服这个看似简单的问题。 rx.Observable .from([1,2,3,54,3,22,323,2...
[RxJS] Handling Multiple Streams with Merge
You often need to handle multiple user interactions set to different streams. This lesson shows hows Observable.merge behaves like a "logical OR" to h...
为什么我们应该使用RxJs Of()函数?
in service section of angular.io tutorial for angular2 I hit a method named of.for example : 在角度2的angular.io教程的服务部分,我点击了一个名为of.for的方法,例如: getHeroes():...
一文带你用80行代码实现简易 RxJS
RxJS 是一个响应式的库,它接收从事件源发出的一个个事件,经过处理管道的层层处理之后,传入最终的接收者,这个处理管道是由操作符组成的,开发者只需要选择和组合操作符就能完成各种异步逻辑,极大简化了异步编程。
[RxJS] Filtering operators: take, first, skip
There are more operators in the filtering category besides filter(). This lesson will teach how take(), first(), and skip() are simply operators to ig...
[RxJS] Filtering operators: distinct and distinctUntilChanged
Operator distinct() and its variants are an important type of Filtering operator. This lessons shows how they work and in what cases are they useful.d...
[RxJS] Transformation operators: debounce and debounceTime
Debounce and debounceTime operators are similar to delayWhen and delay, with the difference that they may drop some emissions. This lesson teaches you...
[RxJS] Transformation operators: delay and delayWhen
This lessons teaches about delay and delayWhen: simple operators that time shift.delay(number | date)var foo = Rx.Observable.interval(500).take(5);/*-...
[RxJS] Filtering operators: takeLast, last
Operators take(), skip(), and first() all refer to values emitted in the beginning of an Observable execution. In this lesson we will see similar oper...
RxJs——创建型操作
我们在使用RxJs中,知道RxJs的操作分为两类,一类是创建型,比如of(),fromEvent(),from()等,还有一类是操作型,比如map(),filter()。如果对Observable不甚理解,需要快速理解的可以查看这一篇今天我们来学习第一类,尝试着自己实现一次。of()这个操作接收一些...
RxJs高阶运算——switchMap
上一节我们学习了mergeMap的相关知识,我们知道了在并发执行的时候,我们可以使用mergeMap来达到效果。今天我们学习另一个高阶运算符switchMap。同样的道理,我们想要学习理解switchMap,我们首先得知道什么是switch?Observable Switchingswitch的概念...
RxJs高阶运算——mergeMap
上一节我们介绍了第一个高阶运算concatMap,今天我们开始学习第二个高阶运算mergeMap。同样的道理,为了掌握mergeMap,我们先了解merge。mergeMap动态图我们知道concatMap是顺序执行,有的时候我们可能需要并行执行,此时我们就要用到merge.Observable M...
RxJs高阶运算——exhaustMap
上一节我们介绍了switchMap的特点,只要一个新的Source Observable到来,我们就订阅新的Observable,那么可能会有另一种情况就是,我们订阅第一个Source Observable,只有当这个Observable都完成的时候,如果之前有新的Observable到来,我们都忽...
RxJs高阶运算——concatMap
在我们的实际使用中,最重用的一些高阶映射运算主要有四类——concatMap,mergeMap,switchMap,exhaustMap这些高阶映射运算符在网络响应式编程中的使用非常广泛,因此理解它们很重要。但是知道在什么场景下使用这些运算符本身就十分困惑,本文就是为了解疑释惑而写,我们后续会在本节...
RxJs——subject理解一
什么是subject首先我们来理解什么是subject,按照官方的定义:A Subject is a special type of Observable that allows values to be multicasted to many Observers.Subjects are like...
RxJs——错误处理(二)
从前文我们知道,错误处理有两种方式,一种是重新抛出一个错误,另一个是提供一个默认的回调值。今天我们介绍错误处理的另一些方式,先来看看重试。重试策略有一点需要记住,一旦流出现了错误,我们不能恢复它。但是没有什么能阻碍我们订阅其派生类对应的Observable,并且创建一个新的流。这种策略的工作原理是:...
RxJs——错误处理(一)
错误处理是RxJs中重要组成部分。我们在响应式编程中几乎都要使用到。然而RxJs中的错误处理不像在其他库中的错误处理那么容易理解。小窍门就是关注Observable的约定,这样就容易理解RxJs中错误处理。 今天我们介绍一些常见的错误处理策略,涵盖一些常用场景,当然还是从Observable的基础知...