December 2019
Intermediate to advanced
598 pages
12h 21m
English
When the user navigates away from the question page, we want to unsubscribe the client from the question and stop the connection. Let's look at the steps to do just that:
const cleanUpSignalRConnection = async ( questionId: number, connection: HubConnection,) => { // TODO - unsubscribe from the question // TODO - stop the connection};
So, our function is asynchronous and takes in the question ID and connection as parameters.
const cleanUpSignalRConnection = async ( questionId: number, connection: HubConnection,) => { if (connection.state === HubConnectionState.Connected) { try ...Read now
Unlock full access