metatext/ViewModels/Sources/ViewModels/IdentitiesViewModel.swift

24 lines
719 B
Swift
Raw Normal View History

2020-08-04 20:26:09 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Combine
import Foundation
2020-08-31 18:57:02 +00:00
import ServiceLayer
2020-08-04 20:26:09 +00:00
2020-09-01 07:33:49 +00:00
public class IdentitiesViewModel: ObservableObject {
@Published public private(set) var identity: Identity
@Published public var identities = [Identity]()
@Published public var alertItem: AlertItem?
2020-08-04 20:26:09 +00:00
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)
}
}