handleStoreEvents method

void handleStoreEvents(
  1. FastStoreBlocEvent event
)

Implementation

void handleStoreEvents(FastStoreBlocEvent event) {
  final payload = event.payload;
  final productId = payload?.productId ?? _pendingPlanRestoring!;
  final type = event.type;
  final error = event.error;

  debugLog('Store event: $type - $productId - $error');

  if (type == FastStoreBlocEventType.productPurchased) {
    addEvent(FastPlanBlocEvent.planPurchased(productId));
  } else if (event.type == FastStoreBlocEventType.purchaseProductFailed) {
    addEvent(FastPlanBlocEvent.purchasePlanFailed(productId, error));
  } else if (type == FastStoreBlocEventType.purchaseProductCanceled) {
    addEvent(FastPlanBlocEvent.purchasePlanCanceled(productId));
  } else if (type == FastStoreBlocEventType.purchaseRestored) {
    addEvent(FastPlanBlocEvent.planRestored(productId));
  } else if (type == FastStoreBlocEventType.restorePurchasesFailed) {
    addEvent(FastPlanBlocEvent.restorePlanFailed(productId, error));
  }
}