Events

Events emitted when there are state changes with the wallet

NearFi currently supports 3 event types

  • signIn: emitted when the current NearFi wallet account is connected to user application

  • signOut: emitted when the user disconnects/sign-outs the wallet from the application

  • accountChanged: emitted when the wallet user switches from the current wallet to another wallet

Code examples

//register
window.nearFiWallet.on("signIn", function() => {
    //write code to proceed after signing in
})
window.nearFiWallet.on("signOut", function() => {
    //write code to proceed after signing out
})
window.nearFiWallet.on("accountChanged", function() => {
    //reload when account changed
    window.location.reload()
})

//remove events
window.nearFiWallet.remove("signIn")

//register event for once used when the application only wants 
// to listen to the first event instance
window.nearFiWallet.once("signIn", function() => {
    //write code to proceed after signing in
})

Last updated