Skip to content

Commit 88410f6

Browse files
authored
1.29.0-0.1.0: [enhancement] - Cleanup Upon Re-Initialization (#604)
* Reset wallet and close socket on re-init * Increment version * Formatting
1 parent 077d190 commit 88410f6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bnc-onboard",
3-
"version": "1.29.0",
3+
"version": "1.29.0-0.1.0",
44
"description": "Onboard users to web3 by allowing them to select a wallet, get that wallet ready to transact and have access to synced wallet state.",
55
"keywords": [
66
"ethereum",

src/onboard.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
} from './interfaces'
3333

3434
import initializeModules from './modules'
35+
import { closeSocketConnection } from './services'
3536

3637
let onboard: any
3738

@@ -57,6 +58,14 @@ function init(initialization: Initialization): API {
5758
console.warn(
5859
'Initializing Onboard and destroying previously initialized instance.'
5960
)
61+
62+
// close WebSocket connection
63+
closeSocketConnection()
64+
65+
// reset the wallet state
66+
resetWalletState()
67+
68+
// destroy svelte instance and remove from DOM
6069
onboard.$destroy()
6170
}
6271

src/services.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ export function getBlocknative(): any {
2828
}
2929
return blocknative
3030
}
31+
32+
export function closeSocketConnection(): void {
33+
blocknative?.destroy()
34+
}

0 commit comments

Comments
 (0)