GithubHelp home page GithubHelp logo

duan-nguyen / rxsocket.io Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rxswiftcommunity/rxsocket.io

0.0 0.0 0.0 596 KB

Rx wrapper over socket.io library with Generic functions

License: MIT License

Ruby 20.70% Swift 79.30%

rxsocket.io's Introduction

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'

Tip💡

If you want to implement socket.io on server side latest version of socket.io does not work with the latest socket.io protocols. check this post on StackOverflow

Author

behrad-kzm, [email protected]

License

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

rxsocket.io's People

Contributors

behrad-kzm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.