0
我有我的服务这种简单的方法:如何在每次使用Rxjs'interval'运算符时执行Angular 2 http调用?
notify(userID: string) {
let _URL = this.baseUrl + '/notification/GetUnseen?userId=' + userID;
this.datatService.set(_URL);
return this.datatService.get()
.flatMap((response) =>
response.json().slice())
.distinct();
}
它返回对象的流包含关于用户的通知信息。我想用间隔运算符每5秒执行一次该调用,而不使用setTimeout?
当我试试这个:
notify(userID: string) {
let _URL = this.baseUrl + '/notification/GetUnseen?userId=' + userID;
this.datatService.set(_URL);
return this.datatService.get()
**.interval(5000)**
.flatMap((response) =>
response.json().slice())
.distinct();
}
我有一个错误。 有何建议?
我正在订阅组件中的方法,thx是关于statfull函数的注释+1 –