Listening to events
Our client was built with an event-first approach, and every module has its own set of events that you can listen to.
Types of events
There are two types of events that you can listen to:
- State change events: These events are triggered when a module’s variable changes value.
All variables are observable, and their corresponding events will always have the same name as the variable, followed by
Changed
. - Custom events: These events represent some specific action that has occurred in the module.
Listening to events
To listen to a module’s event, you need to call the on
method on the module instance,
passing the event name and a callback function as arguments.
You can just as easily remove the listener by calling the off
method on the module instance,
passing the event name and the same callback function as arguments.
You can add a one-off listener by calling the once
method on the module
instance instead of on
.
List of events
You can find all the events that a module emits in the module’s documentation — for instance, take a look at the auth module’s documentation here.
However, for your convenience, below is a list of all the events that the client emits. Please refer to the module’s documentation for more information on each event.
Auth module
authInit
: Emitted when the user initializes authentication, but before it either completes or fails.authSuccess
: Emitted when the user successfully logs in.authFailed
: Emitted when the user fails to log in.loggedOut
: Emitted when the user logs out.userProfileUpdated
: Emitted when the user’s profile is updated.authenticatedUserChanged
: State change event for theauthenticatedUser
variable.tokenChanged
: State change event for thetoken
variable.
Email auth module
emailVerificationFinished
: Emitted when the email verification process is completed.
SMS auth module
smsVerificationFinished
: Emitted when the SMS verification process is completed.
Wallets module
messageSigned
: Emitted when a message is signed.walletAdded
: Emitted when a wallet is added to theuserWallets
variable.walletRemoved
: Emitted when a wallet is removed from theuserWallets
variable.primaryChanged
: State change event for theprimary
variable.userWalletsChanged
: State change event for theuserWallets
variable.
Embedded wallets module
embeddedWalletCreated
: Emitted when an embedded wallet is created.hasWalletChanged
: State change event for thehasWallet
variable.
Networks module
evmChanged
: State change event for theevm
variable.solanaChanged
: State change event for thesolana
variable.
SDK module
error
: Emitted when an error occurs.loadedChanged
: State change event for theloaded
variable.
UI module
authFlowCancelled
: Emitted when the user cancels the authentication flow (closes it before completing it).authFlowClosed
: Emitted when the authentication flow is closed, regardless of whether it was successfully completed or not.authFlowOpened
: Emitted when the authentication flow is opened.
Was this page helpful?