Better observe updates explicitly after init
This commit is contained in:
parent
5cafd9794d
commit
f5c87d43c2
|
@ -139,6 +139,9 @@ class AppContext {
|
|||
self.isEligibleForOnDemandRules()
|
||||
}
|
||||
|
||||
profileManager.observeUpdates()
|
||||
vpnManager.observeUpdates()
|
||||
|
||||
// app
|
||||
|
||||
reviewer.eventCountBeforeRating = Constants.Rating.eventCount
|
||||
|
|
|
@ -78,8 +78,6 @@ public class VPNManager: ObservableObject, RateLimited {
|
|||
isOnDemandRulesSupported = { true }
|
||||
|
||||
currentState = ObservableState()
|
||||
observeStrategy()
|
||||
observeProfileManager()
|
||||
}
|
||||
|
||||
public func toggle() -> Bool {
|
||||
|
@ -156,6 +154,11 @@ public class VPNManager: ObservableObject, RateLimited {
|
|||
// MARK: Observation
|
||||
|
||||
extension VPNManager {
|
||||
public func observeUpdates() {
|
||||
observeStrategy()
|
||||
observeProfileManager()
|
||||
}
|
||||
|
||||
private func observeStrategy() {
|
||||
strategy.observe(into: currentState)
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ public class ProfileManager: ObservableObject {
|
|||
self.strategy = strategy
|
||||
|
||||
currentProfile = ObservableProfile()
|
||||
observeUpdates()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,7 +274,7 @@ extension ProfileManager {
|
|||
}
|
||||
|
||||
extension ProfileManager {
|
||||
private func observeUpdates() {
|
||||
public func observeUpdates() {
|
||||
strategy.willUpdateProfiles()
|
||||
.dropFirst()
|
||||
.sink {
|
||||
|
|
Loading…
Reference in New Issue