perezpaya / RxDecodable

Reactive Decodable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RxDecodable

Build Status

Usage

struct God: RxDecodable {
    let name: String
    let parents: [God]?

    static func decode(j: AnyObject) throws -> God {
        return try God(name: j => "name", parents: j => "parents")
    }
}

let hermes = God.rx_decode(["name": "Hermes",
                            "parents": [["name": "Zeus"],["name": "Maia"]]])

hermes.subscribeError { e in
    print(e)
}.addDisposableTo(self.disposableBag)

hermes.subscribe { g in
    print(g.element?.name) // Hermes
    print(g.element?.parents?.first?.name) // Zeus
    print(g.element?.parents?.last?.name) // Maia
}.addDisposableTo(self.disposableBag)

Installation

Cocoapods

pod 'RxDecodable', '~> 0.1'

About

Reactive Decodable

License:MIT License


Languages

Language:Swift 64.0%Language:Ruby 27.3%Language:Objective-C 8.7%