Latest 0.1.0
Homepage https://github.com/fmo91/RxObjectMapper
License MIT
Platforms ios 8.0
Dependencies ObjectMapper, RxSwift, RxCocoa
Authors

CI Status
Version
License
Platform

Introduction

RxObjectMapper is a set of extensions over Observable<Element> that transforms an Observable<Any> in Observable<T> or Observable<[T]> where T is Mappable.

mapObject

mapObject transforms Observable<Any> into Observable<T> where T is Mappable.

let url = URL(string: "https://jsonplaceholder.typicode.com/posts/1")!

URLSession.shared
    .rx.json(url: url)
    .mapObject(type: Post.self)
    .subscribe(
        onNext: { (post: Post) in
            print("Post title => (post.title)")
        },
        onError: { _ in
            print("Error")
        }
    )
    .addDisposableTo(disposeBag)

mapArray

mapArray transforms Observable<Any> into Observable<[T]> where T is Mappable.

URLSession.shared
    .rx.json(url: URL(string: "https://jsonplaceholder.typicode.com/posts")!)
    .mapArray(type: Post.self)
    .subscribe(
        onNext: { (posts: [Post]) in
            // ...
        },
        onError: { _ in
            print("Error")
        }
    )
    .addDisposableTo(disposeBag)

Example

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

Requirements

RxObjectMapper relies on:

  • RxSwift 3.0
  • RxCocoa 3.0
  • ObjectMapper 2.2
  • Swift 3, of course.

Installation

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

pod "RxObjectMapper"

Author

fmo91, [email protected]

License

RxObjectMapper is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "RxObjectMapper",
    "version": "0.1.0",
    "summary": "A short description of RxObjectMapper.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/fmo91/RxObjectMapper",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "fmo91": "[email protected]"
    },
    "source": {
        "git": "https://github.com/fmo91/RxObjectMapper.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RxObjectMapper/Classes/**/*",
    "dependencies": {
        "ObjectMapper": [
            "~> 2.2"
        ],
        "RxSwift": [
            "~> 3.0"
        ],
        "RxCocoa": [
            "~> 3.0"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This