LinePredictor

cart · /react·type

A function that optimistically projects a single cart line given a pending mutation. Called once per add-line mutation by the projection engine; return a partial line to override the blank placeholder, or null to fall through to the next predictor in the chain.

Definition

@nordcom/commerce-cart
type LinePredictor = (mutation: CartMutation, ctx: PredictorCtx<TExt>) => Partial<CartLine<TExt['line']>> | null;

(mutation: CartMutation, ctx: PredictorCtx<TExt>) => Partial<CartLine<TExt['line']>> | null

Example

const predictors = {
  line: [snapshotPredictor(), cachePredictor({ get: cache.get })],
};

CartDevtools CartFormProps CartProviderProps AppCartConfig BaseCartActions BuyerIdentityActions CartActions CartAttributeActions

Metadata@nordcom/commerce-cart@0.2.2Open in GitHub ↗

On this page