Implementing Get Status Polling
Ensure that:
- The backend exposes a
GET /statusAPI that returns the standard status flags. - An asynchronous operation that triggers pricing and revalidation has been initiated.
Cart pricing and related operations are executed through an asynchronous backend process that includes multiple steps such as pricing, revalidation, and cart processing. Because these operations do not complete within the initial request–response cycle, the UI cannot know when pricing and revalidation have finished just from the action that triggered them.
To expose the progress of these asynchronous steps, the backend provides a
GET /status API. This API returns a set of Boolean flags that describe the
current state of pricing and cart processing. A simplified example response is:
{
"IsPricingPending": false,
"IsPriceProcessingPending": false,
"IsPriceTotalingPending": false,
"IsCartProcessingPending": false,
"IsRevalidationNeeded": false,
"IsApplyRevalidationPending": false,
"IsCartFinalizationPending": true,
"IsHardRevalidation": false,
"IsCollaborationPending": false
}The UI must poll the GET /status API at a regular interval (for example,
every 0.5 seconds) and inspect these flags to determine when processing is
complete. For the polling mechanism, the most important flags are:
IsPriceProcessingPendingIsApplyRevalidationPending
Polling continues while either of these flags is true, and stops when both
become false, or when a timeout or error occurs. Once polling stops, the UI
refreshes pricing and cart details for the affected lines. During polling, users can still
navigate to the configuration page to update configuration or reprice any lines that are not
part of the current polling request.
The UI accurately reflects pricing and cart-processing completion by polling the Get Status API and refreshing cart details when processing is complete.
