Skip to content

addedToFavourites.removed

addedToFavourites.removed is an event on the Event Bus that occurs whenever the product is removed from favourites.

Event body

The addedToFavourites.removed body has a string type which represents the stock id of the removed product. It is optional so it might not exist.

Example

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

useStorefront(async (storefront) => {
    storefront.eventBus.on('addedToFavourites.removed', ({ body: stockId }) => {
        console.log('Product has has been removed from favourites with this stockId:', stockId);
    });
});

Example

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

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

    const pastRemovedEvents = messageStorageApi.getChannelMessages('addedToFavourites.removed');

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

JS API reference