consentsService.showAdvancedConsentsModal¶
consentsService.showAdvancedConsentsModal is an event on the Event Bus that occurs whenever an advanced consents modal is displayed.
Event body¶
none
Example¶
In this example we listen to consentsService.showAdvancedConsentsModal event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('consentsService.showAdvancedConsentsModal', ({ body: consents }) => {
console.log('Advanced consents modal has been displayed:', consents);
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past consentsService.showAdvancedConsentsModal events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastShowAdvancedConsentsModalEvents = messageStorageApi.getChannelMessages('consentsService.showAdvancedConsentsModal');
if (pastShowAdvancedConsentsModalEvents.length > 0) {
pastShowAdvancedConsentsModalEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});