authentication.loggedOut¶
authentication.loggedOut
is an event on the Event Bus that occurs after a user has logged out.
Event body¶
none
Example¶
In this example we listen to authentication.loggedOut
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('authentication.loggedOut', () => {
console.log('A user has logged out!')
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past authentication.loggedOut
events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastLoggedOutEvents = messageStorageApi.getChannelMessages('authentication.loggedOut');
if (pastLoggedOutEvents.length > 0) {
pastLoggedOutEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});