Skip to content

Commit

Permalink
add disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat committed Mar 5, 2024
1 parent 3bacf8e commit e1d2706
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/model/Api/indexi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,22 @@ export class Api {
}
return 'error' as EventStatus;
};

// ------------------------------------------------------
// Disconnect
// ------------------------------------------------------

// Remove API event listeners if they exist.
unsubscribeProvider() {
this.#providerUnsubs.forEach((unsub) => {
unsub();
});
}

// Disconnect gracefully from API and provider.
async disconnect() {
this.unsubscribeProvider();
this.provider?.disconnect();
await this.api?.disconnect();
}
}

0 comments on commit e1d2706

Please sign in to comment.