I have implemented angular 8 snack bar using the default snackbar in angular. However I have an excel extraction happening on the server that i would like to report its progress...I am implementing signalR to send the progress to the client, but not sure how to keep the snackbar alive to show the message (without recreating the snackbar). I was able to achieve it in angularjs using a toaster. Any advice on how to achieve this?
constructor(
private _snackBar: MatSnackBar,
private _ngZone: NgZone)
{}
public startConnection() {
this.hubConnection = new signalR.HubConnectionBuilder()
.withUrl("https://localhost:5001/Signal").build();
this.hubConnection.start().then(() => {
this._snackBar.open("connection started");
}).catch(err => console.log(err));
this.hubConnection.onclose(() => {
setTimeout(() => {
this.hubConnection.start().then(() => {
console.log("connection started");
}).catch(err => console.log(err));
}, 5000);
});
this.hubConnection.on("clientMethodName", (data) => {
this._snackBar.open('Data returned from server '+ data);
console.log(data);
});
this.hubConnection.on("WelcomeMethodName", (data) => {
console.log(data);
this.hubConnection.invoke("GetDataFromClient", data).catch(err => console.log(err));
});
}