when I add a new item, I want the new item to add to head of the md-table dataSouce.
Just like: datas.unshift(newItem). But the md-table use BehaviorSubject of rxjs, I don't know how to do that.
export class DeptDataSource extends DataSource<any> {
constructor(
private deptService: DeptService
) {
super();
}
connect(): Observable<any[]> {
const displayDataChanges = [
this.deptService.dataChange
];
return Observable.merge(...displayDataChanges).map(() => {
const data = this.deptService.getDeptsData();
const { t } = <any>data;
return t;
});
}
disconnect(): void {
this.deptService.dataChange.complete();
}
}