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 //import Bindings
//
public struct ClientCreator { //public struct ClientCreator {
public var create: (URL, Data, Data, String?) throws -> Void // public var create: (URL, Data, Data, String?) throws -> Void
//
public func callAsFunction( // public func callAsFunction(
directoryURL: URL, // directoryURL: URL,
ndf: Data, // ndf: Data,
password: Data, // password: Data,
regCode: String? = nil // regCode: String? = nil
) throws { // ) throws {
try create(directoryURL, ndf, password, regCode) // try create(directoryURL, ndf, password, regCode)
} // }
} //}
//
extension ClientCreator { //extension ClientCreator {
public static let live = ClientCreator { directoryURL, ndf, password, regCode in // public static let live = ClientCreator { directoryURL, ndf, password, regCode in
var error: NSError? // var error: NSError?
let network = String(data: ndf, encoding: .utf8)! // let network = String(data: ndf, encoding: .utf8)!
let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error) // let created = BindingsNewKeystore(network, directoryURL.path, password, regCode, &error)
if let error = error { // if let error = error {
throw error // throw error
} // }
if !created { // if !created {
fatalError("BindingsNewClient returned `false` without providing error") // fatalError("BindingsNewClient returned `false` without providing error")
} // }
} // }
} //}
//
#if DEBUG //#if DEBUG
extension ClientCreator { //extension ClientCreator {
public static let failing = ClientCreator { _, _, _, _ in // public static let failing = ClientCreator { _, _, _, _ in
struct NotImplemented: Error {} // struct NotImplemented: Error {}
throw NotImplemented() // throw NotImplemented()
} // }
} //}
#endif //#endif
import Bindings //import Bindings
//
public struct IdentityMaker { //public struct IdentityMaker {
public var make: () throws -> Identity // public var make: () throws -> Identity
//
public func callAsFunction() throws -> Identity { // public func callAsFunction() throws -> Identity {
try make() // try make()
} // }
} //}
//
extension IdentityMaker { //extension IdentityMaker {
public static func live(bindingsClient: BindingsCmix) -> IdentityMaker { // public static func live(bindingsClient: BindingsCmix) -> IdentityMaker {
IdentityMaker { // IdentityMaker {
let data = try bindingsClient.makeIdentity() // let data = try bindingsClient.makeIdentity()
let decoder = JSONDecoder() // let decoder = JSONDecoder()
return try decoder.decode(Identity.self, from: data) // return try decoder.decode(Identity.self, from: data)
} // }
} // }
} //}
//
#if DEBUG //#if DEBUG
extension IdentityMaker { //extension IdentityMaker {
public static let failing = IdentityMaker { // public static let failing = IdentityMaker {
struct NotImplemented: Error {} // struct NotImplemented: Error {}
throw NotImplemented() // throw NotImplemented()
} // }
} //}
#endif //#endif
import Bindings //import Bindings
//
public struct NetworkHealthListener { //public struct NetworkHealthListener {
public var listen: (@escaping (Bool) -> Void) -> Cancellable // public var listen: (@escaping (Bool) -> Void) -> Cancellable
//
public func callAsFunction(callback: @escaping (Bool) -> Void) -> Cancellable { // public func callAsFunction(callback: @escaping (Bool) -> Void) -> Cancellable {
listen(callback) // listen(callback)
} // }
} //}
//
extension NetworkHealthListener { //extension NetworkHealthListener {
public static func live(bindingsClient: BindingsCmix) -> NetworkHealthListener { // public static func live(bindingsClient: BindingsCmix) -> NetworkHealthListener {
NetworkHealthListener { callback in // NetworkHealthListener { callback in
let listener = Listener(onCallback: callback) // let listener = Listener(onCallback: callback)
let id = bindingsClient.registerNetworkHealthCB(listener) // let id = bindingsClient.registerNetworkHealthCB(listener)
return Cancellable { // return Cancellable {
bindingsClient.unregisterNetworkHealthCB(id) // bindingsClient.unregisterNetworkHealthCB(id)
} // }
} // }
} // }
} //}
//
private final class Listener: NSObject, BindingsNetworkHealthCallbackProtocol { //private final class Listener: NSObject, BindingsNetworkHealthCallbackProtocol {
init(onCallback: @escaping (Bool) -> Void) { // init(onCallback: @escaping (Bool) -> Void) {
self.onCallback = onCallback // self.onCallback = onCallback
super.init() // super.init()
} // }
//
let onCallback: (Bool) -> Void // let onCallback: (Bool) -> Void
//
func callback(_ p0: Bool) { // func callback(_ p0: Bool) {
onCallback(p0) // onCallback(p0)
} // }
} //}
//
#if DEBUG //#if DEBUG
extension NetworkHealthListener { //extension NetworkHealthListener {
public static let failing = NetworkHealthListener { _ in // public static let failing = NetworkHealthListener { _ in
fatalError("Not implemented") // fatalError("Not implemented")
} // }
} //}
#endif //#endif
import Bindings //import Bindings
//
public struct NetworkHealthProvider { //public struct NetworkHealthProvider {
public var get: () -> Bool // public var get: () -> Bool
//
public func callAsFunction() -> Bool { // public func callAsFunction() -> Bool {
get() // get()
} // }
} //}
//
extension NetworkHealthProvider { //extension NetworkHealthProvider {
public static func live(bindingsClient: BindingsCmix) -> NetworkHealthProvider { // public static func live(bindingsClient: BindingsCmix) -> NetworkHealthProvider {
NetworkHealthProvider(get: bindingsClient.isNetworkHealthy) // NetworkHealthProvider(get: bindingsClient.isNetworkHealthy)
} // }
} //}
//
#if DEBUG //#if DEBUG
extension NetworkHealthProvider { //extension NetworkHealthProvider {
public static let failing = NetworkHealthProvider { // public static let failing = NetworkHealthProvider {
fatalError("Not implemented") // fatalError("Not implemented")
} // }
} //}
#endif //#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment