Skip to content

v9.0.0

Compare
Choose a tag to compare
@nuclearace nuclearace released this 07 May 16:17
· 441 commits to master since this release
v9.0.0
b6d0a15

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.