RxJS

作者:frank 发表日期:2017-08-04 22:42:41 更新日期:2017-08-04 22:42:41 分类:猿文色

摘要

We capture these emitted events only asynchronously, by defining a function that will execute when a value is emitted, another function when an error is emitted, and another function when 'completed' is emitted. Sometimes these last two can be omitted and you can just focus on defining the function for values. The "listening" to the stream is called subscribing. The functions we are defining are observers. The stream is the subject (or "observable") being observed.

正文

我们只会异步处理这些发出的事件, 通过定义三个函数来实现, 第一个是当正确的值被射出的时候, 第二个是错误发生的时候, 第三个是完成事件发生的时候. 很多时候我们只需要关注第一个函数即可. 监听的动作称之为订阅. 三个函数称之为观察者. 数据流是被观察的主体(或者可观察对象).