我没有获得带有间隔,switchMap和map的角度为6的rxjs 6 [英] I dont get rxjs 6 with angular 6 with interval, switchMap, and map
本文介绍了我没有获得带有间隔,switchMap和map的角度为6的rxjs 6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我不明白,我想将我的rxjs代码更新为6.
I want to update my rxjs code to 6 got I don't get it.
在我进行下面的每5秒一次的新数据轮询之前:
Before I had the below that wouth poll for new data every 5 seconds:
import { Observable, interval } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';
var result = interval(5000).switchMap(() => this._authHttp.get(url)).map(res => res.json().results);
现在...当然,它已经坏了,文档也让我无处可寻.
Now...of course, it's broken and the documentation leaves me nowhere to go.
我如何编写以上内容以符合rxjs 6?
How do I write the above to conform to rxjs 6?
谢谢
推荐答案
代码应类似于以下内容.您需要使用pipe
运算符.
The code should be something like the following. You need to use the pipe
operator.
import { interval } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';
const result = interval(5000).pipe(
switchMap(() => this._authHttp.get(url)),
map(res => res.results)
)
这篇关于我没有获得带有间隔,switchMap和map的角度为6的rxjs 6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文