All Projects → spxrogers → Moya-Gloss

spxrogers / Moya-Gloss

Licence: MIT license
Gloss bindings for Moya

Programming Languages

swift
15916 projects
ruby
36898 projects - #4 most used programming language
objective c
16641 projects - #2 most used programming language

Projects that are alternatives of or similar to Moya-Gloss

Restofire
Restofire is a protocol oriented networking client for Alamofire
Stars: ✭ 377 (+918.92%)
Mutual labels:  carthage, moya, alamofire
Moyasugar
🍯 Syntactic sugar for Moya
Stars: ✭ 165 (+345.95%)
Mutual labels:  rxswift, moya, alamofire
Rxswiftexamples
Examples and resources for RxSwift.
Stars: ✭ 930 (+2413.51%)
Mutual labels:  rxswift, moya, alamofire
Moya Modelmapper
ModelMapper bindings for Moya.
Stars: ✭ 143 (+286.49%)
Mutual labels:  rxswift, moya, reactivecocoa
Networking
Easy HTTP Networking in Swift a NSURLSession wrapper with image caching support
Stars: ✭ 1,269 (+3329.73%)
Mutual labels:  carthage, moya, alamofire
Evreflection
Reflection based (Dictionary, CKRecord, NSManagedObject, Realm, JSON and XML) object mapping with extensions for Alamofire and Moya with RxSwift or ReactiveSwift
Stars: ✭ 954 (+2478.38%)
Mutual labels:  rxswift, moya, alamofire
Moya
Network abstraction layer written in Swift.
Stars: ✭ 13,607 (+36675.68%)
Mutual labels:  rxswift, reactiveswift, alamofire
Rxalamofire
RxSwift wrapper around the elegant HTTP networking in Swift Alamofire
Stars: ✭ 1,503 (+3962.16%)
Mutual labels:  rxswift, alamofire
Rxcodable
RxSwift wrapper for Codable
Stars: ✭ 110 (+197.3%)
Mutual labels:  rxswift, moya
Easyreact
Are you confused by the functors, applicatives, and monads in RxSwift and ReactiveCocoa? It doesn't matter, the concepts are so complicated that not many developers actually use them in normal projects. Is there an easy-to-use way to use reactive programming? EasyReact is born for this reason.
Stars: ✭ 1,616 (+4267.57%)
Mutual labels:  rxswift, reactivecocoa
Ios
A sample project demonstrating MVVM, RxSwift, Coordinator Pattern, Dependency Injection
Stars: ✭ 49 (+32.43%)
Mutual labels:  rxswift, moya
Rxspritekit
👾 Reactive Extensions for SpriteKit
Stars: ✭ 131 (+254.05%)
Mutual labels:  rxswift, carthage
Swifthub
GitHub iOS client in RxSwift and MVVM-C clean architecture
Stars: ✭ 2,330 (+6197.3%)
Mutual labels:  rxswift, moya
Boilerplate
Swift 4 and Using MVVM architecture(Rxswfit + Moya) to implement Github client demo.
Stars: ✭ 102 (+175.68%)
Mutual labels:  rxswift, moya
Rxmarvel
Playing around marvel public API with RxSwift, Argo, Alamofire
Stars: ✭ 86 (+132.43%)
Mutual labels:  rxswift, alamofire
Moyamapper
快速解析模型工具,支持RxSwift。同时支持缓存功能 【相关手册 https://MoyaMapper.github.io 】
Stars: ✭ 115 (+210.81%)
Mutual labels:  rxswift, moya
Simpleapiclient Ios
A configurable api client based on Alamofire4 and RxSwift4 for iOS
Stars: ✭ 68 (+83.78%)
Mutual labels:  rxswift, alamofire
minimalist
Observable Property and Signal for building data-driven UI without Rx
Stars: ✭ 88 (+137.84%)
Mutual labels:  rxswift, reactiveswift
Zhuishushenqi
追书神器Swift版客户端(非官方)。 不断更新中......
Stars: ✭ 196 (+429.73%)
Mutual labels:  rxswift, reactivecocoa
iOS Started Kit
iOS Started Kit: Clean Architecture + RxSwift + Moya
Stars: ✭ 12 (-67.57%)
Mutual labels:  rxswift, moya

Moya-Gloss

CocoaPods Carthage compatible

Gloss bindings for Moya for fabulous JSON serialization. Supports RxSwift and ReactiveSwift bindings as well.

Installation

CocoaPods

Add to your Podfile:

pod 'Moya-Gloss'

The subspec(s) if you want to use the bindings over RxSwift or ReactiveSwift (or ReactiveCocoa).

pod 'Moya-Gloss/RxSwift'
pod 'Moya-Gloss/ReactiveSwift'

Carthage

github "spxrogers/Moya-Gloss"

Carthage lists Moya and Gloss as explicit dependencies, so it's only necessary to list the above in your Cartfile and it will pull down all three libraries. Carthage will generate three frameworks, MoyaGloss, RxMoyaGloss, and ReactiveMoyaGloss (following the naming convention of the three generated frameworks from Moya).

Note: is only necessary to import one of these variations, otherwise Xcode will give you an "Ambiguous use..." error.

Usage

Define your Model

Create a Class or Struct which implements the Decodable (or Glossy) protocol.

import Foundation
import Gloss

struct Person: JSONDecodable {

  let name: String
  let age: Int?

  init?(json: JSON) {
    guard let name: String = "name" <~~ json
      else { return nil }
    
    self.name = name
    self.age = "age" <~~ json
  }
}

API

mapObject()
mapObject(forKeyPath:)
mapArray()
mapArray(forKeyPath:)

Examples

1. Example with no reactive extension

provider.request(ExampleAPI.GetObject) { (result) in
  switch result {
  case .success(let response):
    do {
      let person = try response.mapObject(Person.self)
      // *OR* the line below for a keyPath
      // let person = try response.mapObject(Person.self, forKeyPath: "person")
      print("Found person: \(person)")
    } catch {
      print(error)
    }
  case .failure(let error):
    print(error)
  }
}

2. Example with RxSwift

provider.request(ExampleAPI.GetObject)
  .mapObject(type: Person.self)
  // *OR* the line below for a keyPath
  // .mapObject(Person.self, forKeyPath: "multi.nested.person")
  .subscribe { (event) in
    switch event {
    case .success(let person):
      print("Found person: \(person)")
      break
    case .error(let error):
      print(error)
      break
    }
  }
  .disposedBy(by: your_preferred_dispose_bag)

3. Example with ReactiveCocoa

provider.request(ExampleAPI.GetObject)
  .mapObject(type: Person.self)
  // *OR* the line below for a keyPath
  // .mapObject(Person.self, forKeyPath: "person")
  .start { (event) in
    switch event {
    case .value(let person):
      print("Found person: \(person)")
    case .failed(let error):
      print(error)
    default:
      break
    }
  }

Contributing

Issues and pull requests are welcome!

Author

Steven Rogers @spxrogers

Thanks ...

... to Harlan Kellaway for creating Gloss, my preferred JSON library :)

... to the Moya team for a wonderful network library.

... to the authors of the existing Moya community extensions for inspiring me to make one for Gloss.

... and finally, to everyone in the community that has contributed back ❤️

License

Moya-Gloss is released under an MIT license. See LICENSE for more information.

Chuck Norris likes a permissive license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].