clean up api again

This commit is contained in:
Erik 2015-11-10 20:02:58 -05:00
parent b35004ef60
commit 71c78e1e12
4 changed files with 8 additions and 8 deletions

View File

@ -17,7 +17,7 @@ socket.on("currentAmount") {data, ack in
socket.emit("update", ["amount": cur + 2.50])
}
ack?.with("Got your currentAmount", "dude")
ack.with("Got your currentAmount", "dude")
}
}

View File

@ -34,10 +34,14 @@ public final class SocketAckEmitter: NSObject {
}
public func with(items: AnyObject...) {
guard ackNum != -1 else {return}
socket.emitAck(ackNum, withItems: items)
}
public func with(items: [AnyObject]) {
guard ackNum != -1 else {return}
socket.emitAck(ackNum, withItems: items)
}
}

View File

@ -24,16 +24,12 @@
import Foundation
private func emitAckCallback(socket: SocketIOClient, num: Int) -> SocketAckEmitter? {
return num != -1 ? SocketAckEmitter(socket: socket, ackNum: num) : nil
}
struct SocketEventHandler {
let event: String
let id: NSUUID
let callback: NormalCallback
func executeCallback(items: [AnyObject], withAck ack: Int = -1, withSocket socket: SocketIOClient) {
self.callback(items, emitAckCallback(socket, num: ack))
func executeCallback(items: [AnyObject], withAck ack: Int, withSocket socket: SocketIOClient) {
self.callback(items, SocketAckEmitter(socket: socket, ackNum: ack))
}
}

View File

@ -25,7 +25,7 @@
import Foundation
public typealias AckCallback = ([AnyObject]) -> Void
public typealias NormalCallback = ([AnyObject], SocketAckEmitter?) -> Void
public typealias NormalCallback = ([AnyObject], SocketAckEmitter) -> Void
public typealias OnAckCallback = (timeoutAfter: UInt64, callback: AckCallback) -> Void
enum Either<E, V> {