Skip to content
Snippets Groups Projects
Commit fced4806 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

WIP

Comment out code that needs to be updated
parent 7aa32332
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings
public struct ClientCreator {
public var create: (URL, Data, Data, String?) throws -> Void
public func callAsFunction(
directoryURL: URL,
ndf: Data,
password: Data,
regCode: String? = nil
) throws {
try create(directoryURL, ndf, password, regCode)
}
}
extension ClientCreator {
public static let live = ClientCreator { directoryURL, ndf, password, regCode in
var error: NSError?
let network = String(data: ndf, encoding: .utf8)!
let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error)
if let error = error {
throw error
}
if !created {
fatalError("BindingsNewClient returned `false` without providing error")
}
}
}
#if DEBUG
extension ClientCreator {
public static let failing = ClientCreator { _, _, _, _ in
struct NotImplemented: Error {}
throw NotImplemented()
}
}
#endif
//import Bindings
//
//public struct ClientCreator {
// public var create: (URL, Data, Data, String?) throws -> Void
//
// public func callAsFunction(
// directoryURL: URL,
// ndf: Data,
// password: Data,
// regCode: String? = nil
// ) throws {
// try create(directoryURL, ndf, password, regCode)
// }
//}
//
//extension ClientCreator {
// public static let live = ClientCreator { directoryURL, ndf, password, regCode in
// var error: NSError?
// let network = String(data: ndf, encoding: .utf8)!
// let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error)
// if let error = error {
// throw error
// }
// if !created {
// fatalError("BindingsNewClient returned `false` without providing error")
// }
// }
//}
//
//#if DEBUG
//extension ClientCreator {
// public static let failing = ClientCreator { _, _, _, _ in
// struct NotImplemented: Error {}
// throw NotImplemented()
// }
//}
//#endif
import Bindings
public struct IdentityMaker {
public var make: () throws -> Identity
public func callAsFunction() throws -> Identity {
try make()
}
}
extension IdentityMaker {
public static func live(bindingsClient: BindingsCmix) -> IdentityMaker {
IdentityMaker {
let data = try bindingsClient.makeIdentity()
let decoder = JSONDecoder()
return try decoder.decode(Identity.self, from: data)
}
}
}
#if DEBUG
extension IdentityMaker {
public static let failing = IdentityMaker {
struct NotImplemented: Error {}
throw NotImplemented()
}
}
#endif
//import Bindings
//
//public struct IdentityMaker {
// public var make: () throws -> Identity
//
// public func callAsFunction() throws -> Identity {
// try make()
// }
//}
//
//extension IdentityMaker {
// public static func live(bindingsClient: BindingsCmix) -> IdentityMaker {
// IdentityMaker {
// let data = try bindingsClient.makeIdentity()
// let decoder = JSONDecoder()
// return try decoder.decode(Identity.self, from: data)
// }
// }
//}
//
//#if DEBUG
//extension IdentityMaker {
// public static let failing = IdentityMaker {
// struct NotImplemented: Error {}
// throw NotImplemented()
// }
//}
//#endif
import Bindings
public struct NetworkHealthListener {
public var listen: (@escaping (Bool) -> Void) -> Cancellable
public func callAsFunction(callback: @escaping (Bool) -> Void) -> Cancellable {
listen(callback)
}
}
extension NetworkHealthListener {
public static func live(bindingsClient: BindingsCmix) -> NetworkHealthListener {
NetworkHealthListener { callback in
let listener = Listener(onCallback: callback)
let id = bindingsClient.registerNetworkHealthCB(listener)
return Cancellable {
bindingsClient.unregisterNetworkHealthCB(id)
}
}
}
}
private final class Listener: NSObject, BindingsNetworkHealthCallbackProtocol {
init(onCallback: @escaping (Bool) -> Void) {
self.onCallback = onCallback
super.init()
}
let onCallback: (Bool) -> Void
func callback(_ p0: Bool) {
onCallback(p0)
}
}
#if DEBUG
extension NetworkHealthListener {
public static let failing = NetworkHealthListener { _ in
fatalError("Not implemented")
}
}
#endif
//import Bindings
//
//public struct NetworkHealthListener {
// public var listen: (@escaping (Bool) -> Void) -> Cancellable
//
// public func callAsFunction(callback: @escaping (Bool) -> Void) -> Cancellable {
// listen(callback)
// }
//}
//
//extension NetworkHealthListener {
// public static func live(bindingsClient: BindingsCmix) -> NetworkHealthListener {
// NetworkHealthListener { callback in
// let listener = Listener(onCallback: callback)
// let id = bindingsClient.registerNetworkHealthCB(listener)
// return Cancellable {
// bindingsClient.unregisterNetworkHealthCB(id)
// }
// }
// }
//}
//
//private final class Listener: NSObject, BindingsNetworkHealthCallbackProtocol {
// init(onCallback: @escaping (Bool) -> Void) {
// self.onCallback = onCallback
// super.init()
// }
//
// let onCallback: (Bool) -> Void
//
// func callback(_ p0: Bool) {
// onCallback(p0)
// }
//}
//
//#if DEBUG
//extension NetworkHealthListener {
// public static let failing = NetworkHealthListener { _ in
// fatalError("Not implemented")
// }
//}
//#endif
import Bindings
public struct NetworkHealthProvider {
public var get: () -> Bool
public func callAsFunction() -> Bool {
get()
}
}
extension NetworkHealthProvider {
public static func live(bindingsClient: BindingsCmix) -> NetworkHealthProvider {
NetworkHealthProvider(get: bindingsClient.isNetworkHealthy)
}
}
#if DEBUG
extension NetworkHealthProvider {
public static let failing = NetworkHealthProvider {
fatalError("Not implemented")
}
}
#endif
//import Bindings
//
//public struct NetworkHealthProvider {
// public var get: () -> Bool
//
// public func callAsFunction() -> Bool {
// get()
// }
//}
//
//extension NetworkHealthProvider {
// public static func live(bindingsClient: BindingsCmix) -> NetworkHealthProvider {
// NetworkHealthProvider(get: bindingsClient.isNetworkHealthy)
// }
//}
//
//#if DEBUG
//extension NetworkHealthProvider {
// public static let failing = NetworkHealthProvider {
// fatalError("Not implemented")
// }
//}
//#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment