Skip to content

changeScore

changeScore is a DOM event that occurs whenever the star rating of a product changes.

Event body

The changeScore body has a { value: number } type which represents the changed score of the product. It is optional so it might not exist.

Example

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

useStorefront(async (storefront) => {
    storefront.eventBus.on('changeScore', (event) => {
        const { value } = event.detail;

        console.log('A score has been changed to:', value);
    });
});