Skip to content

Commit

Permalink
Updated WebSocketProvider to use web-style event listener API.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 13, 2020
1 parent 49e83b0 commit 57fd6f0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/providers/src.ts/websocket-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ export class WebSocketProvider extends JsonRpcProvider {
async destroy(): Promise<void> {
// Wait until we have connected before trying to disconnect
if (this._websocket.readyState === WebSocket.CONNECTING) {
await new Promise((resolve) => {
this._websocket.on("open", () => {
await (new Promise((resolve) => {
this._websocket.onopen = function() {
resolve(true);
});
};

this._websocket.on("error", () => {
this._websocket.onerror = function() {
resolve(false);
});
});
};
}));
}

// Hangup (navigating away from the page that opened the connection)
Expand Down

0 comments on commit 57fd6f0

Please sign in to comment.