metatext/ViewModels/Sources/ViewModels/IdentitiesViewModel.swift
2020-09-07 19:35:28 -07:00

24 lines
725 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import Combine
import Foundation
import ServiceLayer
public final class IdentitiesViewModel: ObservableObject {
public let currentIdentityID: UUID
@Published public var identities = [Identity]()
@Published public var alertItem: AlertItem?
private let identification: Identification
private var cancellables = Set<AnyCancellable>()
public init(identification: Identification) {
self.identification = identification
currentIdentityID = identification.identity.id
identification.service.identitiesObservation()
.assignErrorsToAlertItem(to: \.alertItem, on: self)
.assign(to: &$identities)
}
}