Last active
January 29, 2020 01:40
-
-
Save alexytiger/ed3f93c73cba8d37cb7e2c3e1ec2359b to your computer and use it in GitHub Desktop.
e-book
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accountChanged$ = createEffect( | |
() => | |
fromEvent(this.web3Token, 'accountsChanged').pipe( | |
withLatestFrom(this.store$.pipe(select(fromStore.getAccount))), | |
filter(([accounts, currentAccount]) => !!currentAccount && (currentAccount !== accounts[0])), | |
map(([accounts, currentAccount]) => { | |
console.log('new account', accounts[0]); | |
// to reload browser | |
// based onhttps://medium.com/metamask/no-longer-reloading-pages-on-network-change-fbf041942b44 | |
this.document.location.reload(); | |
}) | |
), | |
{ dispatch: false } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment