Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.44 KB

README.md

File metadata and controls

52 lines (35 loc) · 1.44 KB

ReactiveCodable

Swift 4.0 Platform

ReactiveSwift JSON parsing helpers for Swift 4 JSON decoding. Inspired by: ReactiveMapper

Usage

ReactiveSwift

ReactiveCodable supports JSON mapping for ReactiveSwift on values in a Signal or SignalProducer stream.

// Create model from a JSON dictionary
let jsonSignalProducer: SignalProducer<Data, NSError> = // ...
jsonSignalProducer.mapToType(User.self).startWithResult { result in
    // use the decoded User model
    let user: User? = result.value
}

// Create array of models from array of JSON dictionaries
let jsonSignalProducer: SignalProducer<Any, NSError> = // ...
jsonSignalProducer.mapToType([Task].self).startWithResult { result in
    // use the decoded array of Task models
    let tasks: [Task]? = result.value
}

Version Compatibility

Current Swift compatibility breakdown:

Swift Version Framework Version
4.x 1.x

Installation

Carthage

Add the following line to your Cartfile.

github "gunterhager/ReactiveCodable"

Then run carthage update.