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

Add ConnectionIdProvider

parent b8b94f7a
No related branches found
No related tags found
1 merge request!2Bindings API wrapper
import Bindings
public struct Connection {
public var getId: ConnectionIdProvider
public var isAuthenticated: ConnectionAuthStatusProvider
public var getPartner: ConnectionPartnerProvider
public var send: MessageSender
......@@ -13,6 +14,7 @@ extension Connection {
bindingsConnection: BindingsConnection
) -> Connection {
Connection(
getId: .live(bindingsConnection: bindingsConnection),
isAuthenticated: .live(bindingsConnection: bindingsConnection),
getPartner: .live(bindingsConnection: bindingsConnection),
send: .live(bindingsConnection: bindingsConnection),
......@@ -25,6 +27,7 @@ extension Connection {
bindingsAuthenticatedConnection: BindingsAuthenticatedConnection
) -> Connection {
Connection(
getId: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection),
isAuthenticated: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection),
getPartner: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection),
send: .live(bindingsAuthenticatedConnection: bindingsAuthenticatedConnection),
......@@ -37,6 +40,7 @@ extension Connection {
#if DEBUG
extension Connection {
public static let failing = Connection(
getId: .failing,
isAuthenticated: .failing,
getPartner: .failing,
send: .failing,
......
import Bindings
public struct ConnectionIdProvider {
public var get: () -> Int
public func callAsFunction() -> Int {
get()
}
}
extension ConnectionIdProvider {
public static func live(
bindingsConnection: BindingsConnection
) -> ConnectionIdProvider {
ConnectionIdProvider(get: bindingsConnection.getId)
}
public static func live(
bindingsAuthenticatedConnection: BindingsAuthenticatedConnection
) -> ConnectionIdProvider {
ConnectionIdProvider(get: bindingsAuthenticatedConnection.getId)
}
}
#if DEBUG
extension ConnectionIdProvider {
public static let failing = ConnectionIdProvider {
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