Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fmo91/rxobjectmapper
ObjectMapper extensions for RxSwift
https://github.com/fmo91/rxobjectmapper
ios json rxswift swift
Last synced: 10 days ago
JSON representation
ObjectMapper extensions for RxSwift
- Host: GitHub
- URL: https://github.com/fmo91/rxobjectmapper
- Owner: fmo91
- License: mit
- Created: 2017-01-30T13:32:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-30T13:54:12.000Z (almost 8 years ago)
- Last Synced: 2024-10-11T21:45:35.338Z (2 months ago)
- Topics: ios, json, rxswift, swift
- Language: Swift
- Size: 295 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RxObjectMapper
[![CI Status](http://img.shields.io/travis/fmo91/RxObjectMapper.svg?style=flat)](https://travis-ci.org/fmo91/RxObjectMapper)
[![Version](https://img.shields.io/cocoapods/v/RxObjectMapper.svg?style=flat)](http://cocoapods.org/pods/RxObjectMapper)
[![License](https://img.shields.io/cocoapods/l/RxObjectMapper.svg?style=flat)](http://cocoapods.org/pods/RxObjectMapper)
[![Platform](https://img.shields.io/cocoapods/p/RxObjectMapper.svg?style=flat)](http://cocoapods.org/pods/RxObjectMapper)## Introduction
RxObjectMapper is a set of extensions over `Observable` that transforms an `Observable` in `Observable` or `Observable<[T]>` where T is `Mappable`.
## mapObject
`mapObject` transforms `Observable` into `Observable` where T is `Mappable`.
```swift
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` into `Observable<[T]>` where T is `Mappable`.
```swift
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](http://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod "RxObjectMapper"
```## Author
fmo91, [email protected]
## License
RxObjectMapper is available under the MIT license. See the LICENSE file for more info.