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 01:41:59 +00:00
|
|
|
private let environment: IdentifiedEnvironment
|
2020-08-04 20:26:09 +00:00
|
|
|
private var cancellables = Set<AnyCancellable>()
|
|
|
|
|
2020-08-07 01:41:59 +00:00
|
|
|
init(environment: IdentifiedEnvironment) {
|
2020-08-04 20:26:09 +00:00
|
|
|
self.environment = environment
|
2020-08-07 01:41:59 +00:00
|
|
|
identity = environment.identity
|
2020-08-04 20:26:09 +00:00
|
|
|
|
2020-08-07 01:41:59 +00:00
|
|
|
environment.appEnvironment.identityDatabase.identitiesObservation()
|
2020-08-04 20:26:09 +00:00
|
|
|
.assignErrorsToAlertItem(to: \.alertItem, on: self)
|
|
|
|
.assign(to: &$identities)
|
|
|
|
}
|
|
|
|
}
|