Manos Chorianopoulos

fix rerender campaigns asynchronously

...@@ -38,6 +38,12 @@ import SwiftEventBus ...@@ -38,6 +38,12 @@ import SwiftEventBus
38 tableView.delegate = self 38 tableView.delegate = self
39 tableView.dataSource = self 39 tableView.dataSource = self
40 40
41 + SwiftEventBus.onBackgroundThread(self, name: "ccms_retrieved") { result in
42 + print("===== SwiftEventBus ccms_retrieved =====")
43 + campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
44 + tableView.reloadData()
45 + }
46 +
41 tableView.clipsToBounds = true 47 tableView.clipsToBounds = true
42 tableView.layer.cornerRadius = 30 48 tableView.layer.cornerRadius = 30
43 tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 49 tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
......
...@@ -26,6 +26,12 @@ import UIKit ...@@ -26,6 +26,12 @@ import UIKit
26 tableView.delegate = self 26 tableView.delegate = self
27 tableView.dataSource = self 27 tableView.dataSource = self
28 28
29 + SwiftEventBus.onBackgroundThread(self, name: "ccms_retrieved") { result in
30 + print("===== SwiftEventBus ccms_retrieved =====")
31 + campaigns = swiftApi().mergeGFYCCMSLoyaltyCampaigns(campaigns: swiftApi().getCCMSLoyaltyCampaigns())
32 + tableView.reloadData()
33 + }
34 +
29 tableView.clipsToBounds = true 35 tableView.clipsToBounds = true
30 tableView.layer.cornerRadius = 30 36 tableView.layer.cornerRadius = 30
31 tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 37 tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
7 7
8 import Foundation 8 import Foundation
9 import SwiftUI 9 import SwiftUI
10 +import SwiftEventBus
10 11
11 public struct GlobalVariables { 12 public struct GlobalVariables {
12 static var campaigns: Array<swiftApi.CampaignItemModel> = [] 13 static var campaigns: Array<swiftApi.CampaignItemModel> = []
...@@ -73,6 +74,8 @@ public class swiftApi { ...@@ -73,6 +74,8 @@ public class swiftApi {
73 let ccmsCampaign: Array<LoyaltyContextualOfferModel> = campaigns 74 let ccmsCampaign: Array<LoyaltyContextualOfferModel> = campaigns
74 75
75 GlobalVariables.ccmsCampaigns = campaigns 76 GlobalVariables.ccmsCampaigns = campaigns
77 +
78 + SwiftEventBus.post("ccms_retrieved")
76 } 79 }
77 80
78 public func mergeGFYCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) -> Array<CampaignItemModel> { 81 public func mergeGFYCCMSLoyaltyCampaigns(campaigns: Array<LoyaltyContextualOfferModel>) -> Array<CampaignItemModel> {
......