Skip to content

consentsService.showConsentsModal

consentsService.showConsentsModal is an event on the Event Bus that occurs whenever a basic consents modal is displayed.

Event body

none

Example

In this example we listen to consentsService.showConsentsModal event and perform an action whenever it's emitted.

useStorefront(async (storefront) => {
    storefront.eventBus.on('consentsService.showConsentsModal', ({ body: consents }) => {
        console.log('Basic consents modal has been displayed', consents);
    });
});

Example

In this example we use a Message Storage API to retrieve an array of past consentsService.showConsentsModal events.

useStorefront((storefront) => {
    const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');

    const pastShowConsentsModalEvents = messageStorageApi.getChannelMessages('consentsService.showConsentsModal');

    if (pastShowConsentsModalEvents.length > 0) {
        pastShowConsentsModalEvents.forEach(({ body: eventBody }) => {
            console.log('perform action on every past event');
        });
    }
});

JS API reference