Commit dde9713c by Demid Merzlyakov

IOS-155: rename StoreManager subscribers to observers to avoid confusion, since…

IOS-155: rename StoreManager subscribers to observers to avoid confusion, since this class manages subscriptions.
parent fe6329ff
...@@ -9,12 +9,12 @@ import Foundation ...@@ -9,12 +9,12 @@ import Foundation
import OneWeatherCore import OneWeatherCore
import SwiftyStoreKit import SwiftyStoreKit
public protocol StoreManagerSubscriber { public protocol StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) func storeManagerUpdatedStatus(_ storeManager: StoreManager)
} }
public class StoreManager { public class StoreManager {
private let subscribers = MulticastDelegate<StoreManagerSubscriber>() private let observers = MulticastDelegate<StoreManagerObserver>()
public static let shared = StoreManager() public static let shared = StoreManager()
...@@ -24,8 +24,8 @@ public class StoreManager { ...@@ -24,8 +24,8 @@ public class StoreManager {
public var removeAdsPurchased: Bool { public var removeAdsPurchased: Bool {
didSet { didSet {
if removeAdsPurchased { if removeAdsPurchased {
subscribers.invoke { subscriber in observers.invoke { observer in
subscriber.storeManagerUpdatedStatus(self) observer.storeManagerUpdatedStatus(self)
} }
} }
} }
...@@ -74,13 +74,13 @@ public class StoreManager { ...@@ -74,13 +74,13 @@ public class StoreManager {
} }
//MARK: - Subscribers management //MARK: - Observers management
public func add(subscriber: StoreManagerSubscriber) { public func add(observer: StoreManagerObserver) {
subscribers.add(delegate: subscriber) observers.add(delegate: observer)
} }
public func remove(subscriber: StoreManagerSubscriber) { public func remove(observer: StoreManagerObserver) {
subscribers.remove(delegate: subscriber) observers.remove(delegate: observer)
} }
} }
...@@ -29,7 +29,7 @@ class MenuViewModel: NSObject, ViewModelProtocol { ...@@ -29,7 +29,7 @@ class MenuViewModel: NSObject, ViewModelProtocol {
public init(storeManager: StoreManager = StoreManager.shared) { public init(storeManager: StoreManager = StoreManager.shared) {
self.storeManager = storeManager self.storeManager = storeManager
super.init() super.init()
self.storeManager.add(subscriber: self) self.storeManager.add(observer: self)
} }
public func showAlert(_ title: String?, message: String?) -> Void { public func showAlert(_ title: String?, message: String?) -> Void {
...@@ -282,7 +282,7 @@ extension MenuViewModel: OLInAppStoreManagerUIDelegate { ...@@ -282,7 +282,7 @@ extension MenuViewModel: OLInAppStoreManagerUIDelegate {
} }
} }
extension MenuViewModel: StoreManagerSubscriber { extension MenuViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) { func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
onMain { onMain {
self.delegate?.viewModelDidChange(model: self) self.delegate?.viewModelDidChange(model: self)
......
...@@ -31,7 +31,7 @@ class NWSAlertViewModel: ViewModelProtocol { ...@@ -31,7 +31,7 @@ class NWSAlertViewModel: ViewModelProtocol {
self.featureAvailabilityManager = featureAvailabilityManager self.featureAvailabilityManager = featureAvailabilityManager
self.storeManager = storeManager self.storeManager = storeManager
alertsManager.delegates.add(delegate: self) alertsManager.delegates.add(delegate: self)
self.storeManager.add(subscriber: self) self.storeManager.add(observer: self)
cellFactory.delegate = self cellFactory.delegate = self
} }
...@@ -64,7 +64,7 @@ extension NWSAlertViewModel: CellFactoryDelegate { ...@@ -64,7 +64,7 @@ extension NWSAlertViewModel: CellFactoryDelegate {
} }
} }
extension NWSAlertViewModel: StoreManagerSubscriber { extension NWSAlertViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) { func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
handlePremiumStateChange() handlePremiumStateChange()
} }
......
...@@ -57,7 +57,7 @@ class TodayViewModel: ViewModelProtocol { ...@@ -57,7 +57,7 @@ class TodayViewModel: ViewModelProtocol {
self.configManager = configManager self.configManager = configManager
self.shortsManager = shortsManager self.shortsManager = shortsManager
self.storeManager = storeManager self.storeManager = storeManager
self.storeManager.add(subscriber: self) self.storeManager.add(observer: self)
self.shortsManager.multicastDelegate.add(delegate: self) self.shortsManager.multicastDelegate.add(delegate: self)
self.location = locationManager.selectedLocation self.location = locationManager.selectedLocation
locationManager.add(delegate: self) locationManager.add(delegate: self)
...@@ -197,7 +197,7 @@ extension TodayViewModel: LocationManagerDelegate { ...@@ -197,7 +197,7 @@ extension TodayViewModel: LocationManagerDelegate {
} }
} }
extension TodayViewModel: StoreManagerSubscriber { extension TodayViewModel: StoreManagerObserver {
func storeManagerUpdatedStatus(_ storeManager: StoreManager) { func storeManagerUpdatedStatus(_ storeManager: StoreManager) {
handlePremiumStateChange() handlePremiumStateChange()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment