Refactoring
This commit is contained in:
parent
3a132889c9
commit
933ded0233
|
@ -14,7 +14,6 @@ public final class RootViewModel: ObservableObject {
|
||||||
private let userNotificationService: UserNotificationService
|
private let userNotificationService: UserNotificationService
|
||||||
private let registerForRemoteNotifications: () -> AnyPublisher<Data, Error>
|
private let registerForRemoteNotifications: () -> AnyPublisher<Data, Error>
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
private var navigationViewModelCancellable: AnyCancellable?
|
|
||||||
|
|
||||||
public init(environment: AppEnvironment,
|
public init(environment: AppEnvironment,
|
||||||
registerForRemoteNotifications: @escaping () -> AnyPublisher<Data, Error>) throws {
|
registerForRemoteNotifications: @escaping () -> AnyPublisher<Data, Error>) throws {
|
||||||
|
@ -96,8 +95,8 @@ private extension RootViewModel {
|
||||||
}
|
}
|
||||||
.share()
|
.share()
|
||||||
|
|
||||||
navigationViewModelCancellable = identityPublisher
|
identityPublisher
|
||||||
.filter { [weak self] in $0.id != self?.navigationViewModel?.identityContext.identity.id }
|
.first()
|
||||||
.map { [weak self] in
|
.map { [weak self] in
|
||||||
guard let self = self else { return nil }
|
guard let self = self else { return nil }
|
||||||
|
|
||||||
|
@ -122,6 +121,6 @@ private extension RootViewModel {
|
||||||
|
|
||||||
return NavigationViewModel(identityContext: identityContext)
|
return NavigationViewModel(identityContext: identityContext)
|
||||||
}
|
}
|
||||||
.sink { [weak self] in self?.navigationViewModel = $0 }
|
.assign(to: &$navigationViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue