I am using a mat-table to list the content of the users chosen languages. They can also add new languages using dialog panel. After they added a language and returned back.
Best way to do this is by adding an additional observable to your Datasource implementation.
In the connect method you should already be using Observable.merge
to subscribe to an array of observables that include the paginator.page, sort.sortChange, etc. You can add a new subject to this and call next on it when you need to cause a refresh.
something like this:
export class LanguageDataSource extends DataSource {
recordChange$ = new Subject();
constructor(private languages) {
super();
}
connect(): Observable {
const changes = [
this.recordChange$
];
return Observable.merge(...changes)
.switchMap(() => return Observable.of(this.languages));
}
disconnect() {
// No-op
}
}
And then you can call recordChange$.next()
to initiate a refresh.
Naturally I would wrap the call in a refresh() method and call it off of the datasource instance w/in the component, and other proper techniques.