Refactoring

This commit is contained in:
Justin Mazzocchi 2021-01-27 18:46:19 -08:00
parent 3a132889c9
commit 933ded0233
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C

View file

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