I am using a mat-table
to show a list of articles. I can change the price of different articles. After updating the price of the article I am getting back the updated article (updated resource). I want to refresh my datasource without having to call the getArticles and load all the articles because I have already the updated article.
So I can update the datasource replacing the old for the updated item or which is the proper way to do that?
private updateArticle(value: any, id: string): void {
this.dataService.patchArticle(id,price)
.subscribe(
article => {
this.dataService.getArticles(); //that is unnecessary, I have the updated article in variable 'article'
//this.replaceArticleDatasource(article) //update datasource
.subscribe(
data => {
this.articles = data;
this.dataSource = new MatTableDataSource(this.articles);
});
}
);
}