v9.0.0
What's New
- Some shiny docs
- Adds a new SocketClientEvent enum that can be used to add handlers for client events. All your old style client event handlers will still be called.
Example:
socket.on(clientEvent: .connect) {data, ack in
// Your connect logic
}
- Adds a new type that can be used to check ackStatus.
- You can now specify a type conforms to SocketData and use it in emits.
Example:
struct CustomData : SocketData {
let name: String
let age: Int
func socketRepresentation() -> SocketData {
return ["name": name, "age": age]
}
}
socket.emit("myEvent", CustomData(name: "Erik", age: 24))
socket.on('myEvent', (myObject) => {
console.log(`Got custom object. ${myObject['name']} ${myObject['age']}`)
})
Breaking Changes
- The way dispatch queues has been redone. This means more work is done on the
handleQueue
. So if you had the handleQueue as the default (the main queue) it is advised that you create a specific queue for the socket, and dispatch to main from it. All interaction with the socket should be done through the queue that is passed to the socket. - Adds a new client event named
.statusChange
that is emitted whenever the client's status changes.