Here is my current setup:
export class TableComponent<T> implements OnInit {
displayedColumns: Array<string> = [];
dataSource: MatTableDataSource<T> = new MatTableDataSource();
constructor(public asmErrorServ: AssemblyErrorService) { }
ngOnInit(): void {
this.displayedColumns = ['Message Type', 'Message', 'Message Date'];
this.dataSource = (<any>this.asmErrorServ).asmErrorLog;
}
}
The data source is updated from the asmErrorServ, which stores real-time errors or warnings in an array. This part of the code can be found in the error service:
export class AssemblyErrorService{
...
error(message: string): void {
let newError: asmMessage = { type: 'error', message: message, time: Date.now() };
this.asmErrorLog.push(newError);
this._snackBar.open(this.generateSnackbarString(newError), 'Dismiss', {
duration: 3000,
horizontalPosition: this.horizontalPosition,
verticalPosition: this.verticalPosition,
panelClass: ['red-snackbar', 'login-snackbar'],
});
}
}
The table does not update in real time despite these changes. I am seeking advice on how to address this issue. Any suggestions?