Skip to content

selectIsProductNotificationPossible$(productVariantId: number): Observable<boolean>

The selectIsProductNotificationPossible$ method allows to get the information about the current possibility to send a notification about a given product to the authenticated user.

Returned value

A returned value has a type of Observable<boolean> indicating whether or not it is currently possible to send a product notification.

Example

In this example we make a UserApi call to get the information about the current possibility to send a notification about a given product to the authenticated user.

Note that for the sake of example simplicity we wrote an id of some product variant by hand, however in real world this data usually gets passed to webcomponents within a product context with the help of Twig and ObjectApi.

    useStorefront(async (storefront) => {
        const userApi = await storefront.getApi('UserApi');

        const exampleProductVariantId = 1;

        const isNotificationPossible$ = userApi.selectIsProductNotificationPossible$(exampleProductVariantId);

        isNotificationPossible$.subscribe((isNotificationPossible) => {
            if (isNotificationPossible) {
                console.log(`it is currently possible to send a notification about product variant with id ${exampleProductVariantId} to the user`);
            }
            else {
                console.log(`it is not currently possible to send a notification`);
            }
        });
    });

User API methods reference