2020-08-04 20:26:09 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Combine
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
class IdentitiesViewModel: ObservableObject {
|
|
|
|
@Published private(set) var identity: Identity
|
|
|
|
@Published var identities = [Identity]()
|
|
|
|
@Published var alertItem: AlertItem?
|
|
|
|
|
2020-08-07 22:18:54 +00:00
|
|
|
private let identityRepository: IdentityRepository
|
2020-08-04 20:26:09 +00:00
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-08-07 22:18:54 +00:00
|
|
|
init(identityRepository: IdentityRepository) {
|
|
|
|
self.identityRepository = identityRepository
|
|
|
|
identity = identityRepository.identity
|
2020-08-04 20:26:09 +00:00
|
|
|
|
2020-08-07 22:18:54 +00:00
|
|
|
identityRepository.identitiesObservation()
|
2020-08-04 20:26:09 +00:00
|
|
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
|
|
|
.assign(to: &$identities)
|
|
|
|
}
|
|
|
|
}
|