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

Add Listen functor

parent d5bd13ea
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
import Bindings
import XCTestDynamicOverlay
public struct Listen {
public var run: (Int, String, SingleUseCallback) throws -> Cancellable
public func callAsFunction(
e2eId: Int,
tag: String,
callback: SingleUseCallback
) throws -> Cancellable {
try run(e2eId, tag, callback)
}
}
extension Listen {
public static let live = Listen { e2eId, tag, callback in
var error: NSError?
let stopper = BindingsListen(
e2eId,
tag,
callback.makeBindingsSingleUseCallback(),
&error
)
if let error = error {
throw error
}
guard let stopper = stopper else {
fatalError("BindingsListen returned `nil` without providing error")
}
return Cancellable {
stopper.stop()
}
}
}
extension Listen {
public static let unimplemented = Listen(
run: XCTUnimplemented("\(Self.self)")
)
}
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