do not poll for account changes but use the web3 subscription
Open
- Dominant language
- TypeScript
- Stars
- 14
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
```
export function subscribeToAccountChanges(web3: any, currentAccountAddress?: Address) {
let prevAccount = currentAccountAddress;
return Observable.create((observer: any) => {
const sub = web3.on("accountsChanged", (accounts: Address[]) => {
const account = accounts[0];
if (prevAccount !== account && account) {
console.log(`ACCOUNT CHANGED; new account is ${account}`);
observer.next(account);
prevAccount = account;
}
}
);
return () => sub.unsubscribe();
});
}
```
Contributor guide
Assessment
This issue has not been assessed yet.