From 933ded023305316c1137183b13473330cfb0404c Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Wed, 27 Jan 2021 18:46:19 -0800 Subject: [PATCH] Refactoring --- .../Sources/ViewModels/View Models/RootViewModel.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift b/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift index c4b3c11..4b2d9f9 100644 --- a/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift +++ b/ViewModels/Sources/ViewModels/View Models/RootViewModel.swift @@ -14,7 +14,6 @@ public final class RootViewModel: ObservableObject { private let userNotificationService: UserNotificationService private let registerForRemoteNotifications: () -> AnyPublisher private var cancellables = Set() - private var navigationViewModelCancellable: AnyCancellable? public init(environment: AppEnvironment, registerForRemoteNotifications: @escaping () -> AnyPublisher) 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) } }