RxJS为Angular2提供了哪些功能? [英] What functionalities that RxJS provide for Angular2?
问题描述
There is some references of RxJS in the Angular2 project. What is RxJS being used for in Angular2?
推荐答案
angular2使用RxJS的列表
A list of what angular2 uses RxJS for
- Http(例如其
get
方法返回Observable
) - EventEmitter (就像您说的那样,从
Subject
开始) - AsyncPipe 支持
Promise
,Observable
或EventEmitter
. - QueryList的
changes
方法返回EventEmitter
. 更新 - NG_ASYNC_VALIDATORS 实现了
- Http (for example its
get
method returns anObservable
) - EventEmitter (like you said, extends from
Subject
) - AsyncPipe which supports
Promise
,Observable
orEventEmitter
. - QueryList's
changes
method returns anEventEmitter
. Update - NG_ASYNC_VALIDATORS which implements
Validator
and overrides the methodvalidate
to return either aPromise
or anObservable
. Update
有关NG_ASYNC_VALIDATORS的说明
NG_ASYNC_VALIDATORS
不直接使用Observable
,它不订阅它们,而是将它们转换为Promises
,在任何情况下,NG_ASYNC_VALIDATORS
仍接受Observables
.查看#104 validators.ts
中的a>.
NG_ASYNC_VALIDATORS
doesn't use Observable
directly, it doesn't subscribe to them but converts them to Promises
, in any case, NG_ASYNC_VALIDATORS
still accepts Observables
. Look at line #104 in validators.ts
.
感谢@przemcio的观察.
Thanks to @przemcio for the observation.
尚未实施/正在对话
- ObserveChild ,它将返回
EventEmitter
. - ObserveChildren 更新
- ObserveChild which would return an
EventEmitter
. - ObserveChildren Update
注意
他们正在使用裸操作符来处理RxJS包,请参见问题#5288 .这个想法是用最少的所需运算符分发angular2,并让用户提供其余的运算符.
They are working on bundle RxJS with the bare operators, see issue #5288. The idea is to distribute angular2 with the minimal required operators and make the user to provide the rest of them.
注释更新
就像我被告知此处和
Like I was told here and here (I had a problem with importing Subject
) they're working on removing completely Subject
, so from core we would be able to import only Observable
, everything else should be provided by the developer.
PS
我想不出其他任何办法,如果我还记得其他事情,我会更新答案.
I can't think of any other, if I remember of something else I'll update the answer.
这篇关于RxJS为Angular2提供了哪些功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!