Manos Chorianopoulos

fix rerender campaigns asynchronously

......@@ -37,6 +37,12 @@ import SwiftEventBus
tableView.delegate = self
tableView.dataSource = self
SwiftEventBus.onBackgroundThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
tableView.reloadData()
}
tableView.clipsToBounds = true
tableView.layer.cornerRadius = 30
......
......@@ -25,6 +25,12 @@ import UIKit
tableView.delegate = self
tableView.dataSource = self
SwiftEventBus.onBackgroundThread(self, name: "ccms_retrieved") { result in
print("===== SwiftEventBus ccms_retrieved =====")
campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
tableView.reloadData()
}
tableView.clipsToBounds = true
tableView.layer.cornerRadius = 30
......
......@@ -7,6 +7,7 @@
import Foundation
import SwiftUI
import SwiftEventBus
public struct GlobalVariables {
static var campaigns: Array<swiftApi.CampaignItemModel> = []
......@@ -73,6 +74,8 @@ public class swiftApi {
let ccmsCampaign: Array<LoyaltyContextualOfferModel> = campaigns
GlobalVariables.ccmsCampaigns = campaigns
SwiftEventBus.post("ccms_retrieved")
}
public func mergeGFYCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) -> Array<CampaignItemModel> {
......