PageManager.beforeFetchedResponse¶
PageManager.beforeFetchedResponse
is an event on the Event Bus that occurs whenever a Turbo.before-fetch-response event is fired in a page. To read more about Turbo visit the Page Manager Api documentation
Event body¶
Visit a Turbo.before-fetch-response event documentation page to get the information about the data available as the event body.
Example¶
In this example we listen to PageManager.beforeFetchedResponse
event and perform an action whenever it's emitted.
useStorefront(async (storefront) => {
storefront.eventBus.on('PageManager.beforeFetchedResponse', () => {
console.log('This fires before the fetch request completes');
});
});
Example¶
In this example we use a Message Storage API to retrieve an array of past PageManager.beforeFetchedResponse
events.
useStorefront((storefront) => {
const messageStorageApi = storefront.getApiSync('messageStorageSystemApi');
const pastBeforeFetchedResponseEvents = messageStorageApi.getChannelMessages('PageManager.beforeFetchedResponse');
if (pastBeforeFetchedResponseEvents.length > 0) {
pastBeforeFetchedResponseEvents.forEach(({ body: eventBody }) => {
console.log('perform action on every past event');
});
}
});