What functionalities that RxJS provide for Angular2?

最后都变了- 提交于 2019-12-10 10:19:31

问题


There is some references of RxJS in the Angular2 project. What is RxJS being used for in Angular2?


回答1:


A list of what angular2 uses RxJS for

  • Http (for example its get method returns an Observable)
  • EventEmitter (like you said, extends from Subject)
  • AsyncPipe which supports Promise, Observable or EventEmitter.
  • QueryList's changes method returns an EventEmitter. Update
  • NG_ASYNC_VALIDATORS which implements Validator and overrides the method validate to return either a Promise or an Observable. Update

Note about NG_ASYNC_VALIDATORS

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.

Thanks to @przemcio for the observation.

Not yet implemented / In conversation

  • ObserveChild which would return an EventEmitter.
  • ObserveChildren Update

Note

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.

Note update

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.



来源:https://stackoverflow.com/questions/33860374/what-functionalities-that-rxjs-provide-for-angular2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!