Angular 2和RxJS [英] Angular 2 and RxJS

查看:41
本文介绍了Angular 2和RxJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Angular 2.0.0RC5和RxJS 5.0.0-beta.6构建示例实时应用程序.尽管我都使用此代码:

I am trying to build an example realtime app with Angular 2.0.0RC5 and RxJS 5.0.0-beta.6. Although I it is all working with this code:

import {IntervalObservable} from 'rxjs/observable/IntervalObservable';
    ...
return IntervalObservable.create(1000)
                .flatMap(() => this.http.get('filename.json'))
                .map(this.extractDataCallBack)
                .catch(this.handleError);

这是正确的方法吗?当前的RxJS api文档似乎指定了不同的方法.有没有一种方法可以升级到最新版本的RxJS而又不会破坏所有功能?

Is this the correct way? The current RxJS api docs seem to specify different methods. Is there a way to upgrade to the latest version of RxJS without breaking everything?

Observable.interval()函数怎么了?我已经看到了几个使用此示例.

What happened to the Observable.interval() function? I have seen several examples using this.

您可以提供的任何可以将一点光照射到上面的东西都是很棒的.

Anything you can offer to shine a bit of light onto this would be great.

非常感谢

JT

推荐答案

Observable.interval 只是 IntervalObservable.create 的快捷方式:

https://github.com/ReactiveX/rxjs/blob/master/src/observable/interval.ts

这篇关于Angular 2和RxJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆