metatext/View Models/IdentitiesViewModel.swift

23 lines
671 B
Swift
Raw Normal View History

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-08 23:08:47 +00:00
private let identityService: IdentityService
2020-08-04 20:26:09 +00:00
private var cancellables = Set<AnyCancellable>()
2020-08-08 23:08:47 +00:00
init(identityService: IdentityService) {
self.identityService = identityService
identity = identityService.identity
2020-08-04 20:26:09 +00:00
2020-08-08 23:08:47 +00:00
identityService.identitiesObservation()
2020-08-04 20:26:09 +00:00
.assignErrorsToAlertItem(to: \.alertItem, on: self)
.assign(to: &$identities)
}
}