1
我我的角度分2次服我有這樣的方法:Rxjs Angular 2中的按鍵選擇符不同的運算符?
notify(userID: string) {
return Observable.interval(5000)
.map(() => this.baseUrl + '/notification/GetUnseen?userId=' + userID)
.switchMap(url => {
this.datatService.set(url);
return this.datatService.get();
})
.flatMap(response => response.json().slice())
.distinct(function (x) { return x.id });
}
如何使用與鍵選擇不同的運營商在這CAS? 當我嘗試這樣做時,我有這個錯誤:類型'{}'上不存在屬性'id'。
UPDATE:
最後的結果我用這種方法得到的是:
{
id:"f3055770-6e66-4936-8e9a-732b53121549"
message:"Empty Notification for test ......"
navigationLink:"/api/home"
seen:false
sendedOn:"2016-12-02T15:19:44.856Z"
userId:null
}
我想過濾的結果,所以,如果我已經有我不通知想再次獲得
無法讓爲例在我的情況下工作,也許我'失去了一些東西 –
當我試試這個: 通知(用戶名:字符串){ 回報Observable.interval(5000) .map(()=> this.baseUrl +'/ notification/GetUnseen?userId ='+ userID) .switchMap(url => { return Observable.from(this.datatService.get url)); }) .flatMap(response => Observable.fro m(response.json()。slice())) .distinct(x => x.id); } 我只有一個對象而不是四個! –
它對我有很大幫助,請您進一步解釋爲什麼我們需要再次創建觀察點 –