mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-06 00:39:31 +00:00
Ensure unused publishers are canceled
This commit is contained in:
parent
555d436cf5
commit
aa08b9b284
1 changed files with 3 additions and 2 deletions
|
@ -14,6 +14,7 @@ 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 {
|
||||
|
@ -95,7 +96,7 @@ private extension RootViewModel {
|
|||
}
|
||||
.share()
|
||||
|
||||
identityPublisher
|
||||
navigationViewModelCancellable = identityPublisher
|
||||
.filter { [weak self] in $0.id != self?.navigationViewModel?.identityContext.identity.id }
|
||||
.map { [weak self] in
|
||||
guard let self = self else { return nil }
|
||||
|
@ -121,6 +122,6 @@ private extension RootViewModel {
|
|||
|
||||
return NavigationViewModel(identityContext: identityContext)
|
||||
}
|
||||
.assign(to: &$navigationViewModel)
|
||||
.sink { [weak self] in self?.navigationViewModel = $0 }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue