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 ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketPaymentsApi = await getApi('basketPaymentsApi');

        const paymentOptions$ = basketPaymentsApi.select$();

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

Basket Payments API methods reference

Models reference