i my angular 2 service i have this method :
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 });
}
How can i use the distinct operator with key selector in this cas ? When i try to do it i have this error : Property 'id' does not exist on type '{}'.
UPDATE :
The final result i get with this method is :
{
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
}
I would like to filter the result, so if i already have the notification i dont want to get in again