RxSocket.io 1.0.5

RxSocket.io 1.0.5

Maintained by RxSwift Community, Behrad Kazemi.



 
Depends on:
RxSwift>= 0
RxCocoa>= 0
Socket.IO-Client-Swift>= 0
 

Listen to a codable!

With this library your distance to whole socket complexity is a single line of code. Simple, readable, userful:

let observable: Observable<MyCodable> = socket.observe(eventName: "message_updates")

But how?

This library uses PublishSubjects and if the codable model decoded successfully, then the decoded object will send into that publishSubjec and return observable version of it.

// RxSocketTerminalInterface & RxSocketToggle protocols
let rxSocket = RxSocketProvider().makeSocketHandler(auth:["token": "your_token"], url: your_url) 

rxSocket.start().subscribe().disposedBy(disposeBag)

rxSocket.send(eventName: "your_event_name", model: myCodable)

functionalities are separated into 2 different protocols:

1- SocketToggle

This is for connect or disconnect mostly recommended to use where you don't want to listen any model for example inside the AppDelegate.

this only allows you to connect and disconnect socket

let socketToggle: RxSocketToggle = RxSocketProvider().makeSocketHandler(auth:["token": "your_token"], url: your_url)

socketToggle.start().subscribe().disposedBy(disposeBag)

socketToggle.stop()

2- SocketMessage

This is for send and receive models in specific eventNames.

this only allows you to listen for a model or sending it on a specific event.

let socketTerminal: RxSocketTerminalInterface = RxSocketProvider().makeSocketHandler(auth:["token": "your_token"], url: your_url)

let observable: Observable<MyCodable> = socketTerminal.observe(eventName: "your_event_name")

socketTerminal.send(eventName: "your_event_name", model: myCodable)

RxSocket.io

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • RxSwift
  • Socket.io

Installation

RxSocket.io is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'RxSocket.io'

Author

behrad-kzm, [email protected]

License

RxSocket.io is available under the Copyright © RxSwiftCommunity. See the LICENSE file for more info.