Latest 1.1.0
Homepage https://github.com/MihaelIsaev/RxCodyFire
License MIT
Platforms ios 8.0
Dependencies CodyFire, RxSwift, RxCocoa
Authors

Version
License
Platform

Installation

via CocoaPods

pod 'RxCodyFire'

How to use

Please see API declaration examples in the original CodyFire repo https://github.com/MihaelIsaev/CodyFire

Let’s imagine that you have ToDos app. Our goal is to get a list of ToDos.

Ok, let’s declare a ToDo model in Models/ToDoModel.swift

struct ToDoModel: Codable {
    let id: UUID
    let text: String
    let createdAt: Date
}

Then declare your API class in /API/API.swift file

class API {
    typealias todo = ToDoController
}

Then declare your empty ToDo controller in API/Controllers/ToDoController.swift file

class ToDoController {}

And in a separated decorator API/Controllers/ToDo+Search.swift file declare a search endpoint

import RxCodyFire

extension ToDoController {
    struct Query: Codable {
        let text: String
    }
    static func search(_ text: String) -> APIRequest<[ToDo]> {
        return APIRequest("todo").query(Query(text: text))
    }
}

When everything is ready you’re able to easily use it in your reactive code!
Please don’t forget to import RxCodyFire

searchController.searchBar.rx.text.asObservable()
  .map { ($0 ?? "").lowercased() }
  .flatMap { API.todos.search($0).observable }
  .bind(to: tableView.rx.items(cellIdentifier: cellIdentifier)) { index, model, cell in
    cell.textLabel?.text = model.name
  }
  .disposed(by: disposeBag)

Nice, right?

TIP: There is no need to also import CodyFire cause it's already imported by RxCodyFire

Author

Mihael Isaev, [email protected]

License

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

Latest podspec

{
    "name": "RxCodyFire",
    "version": "1.1.0",
    "summary": "CodyFire wrapper for RxSwift ud83dudd25",
    "description": "Install this pod to use CodyFire with RxSwift ud83dudd25",
    "homepage": "https://github.com/MihaelIsaev/RxCodyFire",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "MihaelIsaev": "[email protected]"
    },
    "source": {
        "git": "https://github.com/MihaelIsaev/RxCodyFire.git",
        "tag": "1.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RxCodyFire/Classes/**/*",
    "dependencies": {
        "CodyFire": [],
        "RxSwift": [
            "~> 4.3.1"
        ],
        "RxCocoa": [
            "~> 4.3.1"
        ]
    },
    "swift_version": "4.1.2"
}

Pin It on Pinterest

Share This