Skip to content

select$(): Observable<BasketPayment[]>

The select$ method provides an observable stream of the basket payment options, allowing you to subscribe to changes in the available payment methods.

Returned value

A returned value has a type of Observable<BasketPayment[]> where BasketPayment represents the BasketPayment model, which emits the current list of available payment methods and updates whenever changes occur.

Example

In this example, we subscribe to the select$ observable to react to any changes in the available payment options.

useStorefront(async (storefront) => {
    let basketPaymentsApi = storefront.getApiSync('basketPaymentsApi');

    if (!basketPaymentsApi) {
        const featureSystemApi = this.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('basket');

        basketPaymentsApi = storefront.getApiSync('basketPaymentsApi');
    }

    const paymentOptions$ = basketPaymentsApi.select$();

    paymentOptions$.subscribe((paymentOptions) => {
        console.log('Updated payment options:', paymentOptions);
    });
});

Basket Payments API methods reference

Models reference