Combine stuff

This commit is contained in:
Max Goedjen
2020-03-08 20:44:15 -07:00
parent 2f3f5681e7
commit 286e2dc558
2 changed files with 16 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import Foundation
import Combine
public class AnySecretStore: SecretStore {
@@ -8,6 +9,7 @@ public class AnySecretStore: SecretStore {
fileprivate let _name: () -> String
fileprivate let _secrets: () -> [AnySecret]
fileprivate let _sign: (Data, AnySecret) throws -> Data
fileprivate var sink: AnyCancellable?
public init<SecretStoreType>(_ secretStore: SecretStoreType) where SecretStoreType: SecretStore {
base = secretStore
@@ -16,6 +18,9 @@ public class AnySecretStore: SecretStore {
_id = { secretStore.id }
_secrets = { secretStore.secrets.map { AnySecret($0) } }
_sign = { try secretStore.sign(data: $0, with: $1 as! SecretStoreType.SecretType) }
sink = secretStore.objectWillChange.sink { _ in
self.objectWillChange.send()
}
}
public var isAvailable: Bool {