Hi trying to find the best way to update component views, when a database has been modified,
At the moment I subscribe to an observable to get all records
getBlogs(){
return this._http.get(this.blogsURL+'blogs')
.map((result: Response ) => {
this.blogs = result['blogs'];
return this.blogs;
})
}
And then
this.blogsService.getBlogs()
.subscribe((res)=>{
this.blogs = res;
console.log(res)
})
that's fine but when records update, the views in components don't. I can remedy this via a subject and when the getBlogs and update blogs functions are fired update it
this.populateList = new Subject<Blog[]>();
this.populateList.next(blogs)
Then subscribe, so I end up with something like this?
this.blogsService.getBlogs()
.subscribe((res)=>{
// this.blogs = res;
//console.log(res)
})
this.blogsService.populateList
.subscribe((res)=>{
this.blogs = res;
console.log(res)
})
but I'd like to get it all it to one subscription, maybe mergeMap switchMap? hope this makes sense