Events
The Avana Wallet provider emits the following events:
Event | Description |
---|---|
connect | Emitted when a successful connection has been established |
disconnect | Emitted when app or user disconnects |
popupOpened | Emitted when popup window is opened |
popupClosed | Emitted when popup window is closed |
Handling Popup Close
A popupClosed
event signals that the window closed, but it does not provide context regarding why the window closed.
For example, when calling window.solana.connect()
a popup will close after a user connects, and it also will close if the user rejects
the request. It is recommended to await the popup response promise to determine if
the request was successful or rejected.
Event Listener Examples
Connect Event Listener
window.solana.on('connect', function () {
console.log('Connected 😃');
});
React Connect
import React
React.useEffect(() => {
window.solana.connect({onlyIfTrusted: true})
.then(({ publicKey })) => {
// Proceed with connection
})
.catch((error) => {
console.log(error)
});
},[]);
Disconnect Event Listener
window.solana.on('disconnect', function () {
console.log('Disconnected 🙀');
});
Popup Opened Event Listener
window.solana.on('popupOpened', function () {
console.log('Popup Opened 🙏');
});
Popup Closed Event Listener
window.solana.on('popupClosed', function () {
console.log('Popup Closed 💥🔨');
});