RxAlamofire alternatives and similar libraries
Based on the "Reactive Programming" category.
Alternatively, view RxAlamofire alternatives based on common mentions on social networks and blogs.
-
ReactiveCocoa
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift. -
OpenCombine
Open source implementation of Apple's Combine framework for processing values over time. -
Katana
Swift Apps in a Swoosh! A modern framework for creating iOS apps, inspired by Redux. -
RxCoordinator
๐ Powerful navigation library for iOS based on the coordinator pattern -
Interstellar
Simple and lightweight Functional Reactive Coding in Swift for the rest of us. :large_orange_diamond: -
RxAutomaton
๐ค RxSwift + State Machine, inspired by Redux and Elm. -
NSObject-Rx
Handy RxSwift extensions on NSObject, including rx.disposeBag. -
Verge
๐ฃ A robust Swift state-management framework designed for complex applications, featuring an integrated ORM for efficient data handling. -
RxMediaPicker
A reactive wrapper built around UIImagePickerController. -
VueFlux
:recycle: Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux -
Komponents ๐ฆ
๐ฆ React-inspired UIKit Components - โ ๏ธ Deprecated -
ReactiveTask
Flexible, stream-based abstraction for launching processes -
TemplateKit
React-inspired framework for building component-based user interfaces in Swift. -
RxReduce
Lightweight framework that ease the implementation of a state container pattern in a Reactive Programming compliant way. -
LightweightObservable
๐ฌ A lightweight implementation of an observable sequence that you can subscribe to. -
Aftermath
:crystal_ball: Stateless message-driven micro-framework in Swift. -
RxMultipeer
A testable RxSwift wrapper around MultipeerConnectivity -
ReactiveArray
An array class implemented in Swift that can be observed using ReactiveCocoa's Signals -
SimpleApiClient
A configurable api client based on Alamofire4 and RxSwift4 for iOS. -
ACKReactiveExtensions
Set of useful extensions for ReactiveSwift & ReactiveCocoa -
ReactiveLocation
ReactiveCocoa wrapper for CLLocationManager. -
BindKit
Two-way data binding framework for iOS. Only one API to learn. -
STDevRxExt
STDevRxExt contains some extension functions for RxSwift and RxCocoa which makes our live easy. -
RxOptional
RxSwift extentions for Swift optionals and "Occupiable" types -
RxAlamoRecord
RxAlamoRecord combines the power of the AlamoRecord and RxSwift libraries to create a networking layer that makes interacting with API's easier than ever reactively.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of RxAlamofire or a related project?
README
RxAlamofire
RxAlamofire is a RxSwift wrapper around the elegant HTTP networking in Swift Alamofire.
Getting Started
Wrapping RxSwift around Alamofire makes working with network requests a smoother and nicer task. Alamofire is a very powerful framework and RxSwift add the ability to compose responses in a simple and effective way.
A basic usage is (considering a simple currency converter):
let formatter = NSNumberFormatter()
formatter.numberStyle = .currencyStyle
formatter.currencyCode = "USD"
if let fromValue = NSNumberFormatter().numberFromString(self.fromTextField.text!) {
RxAlamofire.requestJSON(.get, sourceStringURL)
.debug()
.subscribe(onNext: { [weak self] (r, json) in
if let dict = json as? [String: AnyObject] {
let valDict = dict["rates"] as! Dictionary<String, AnyObject>
if let conversionRate = valDict["USD"] as? Float {
self?.toTextField.text = formatter
.string(from: NSNumber(value: conversionRate * fromValue))
}
}
}, onError: { [weak self] (error) in
self?.displayError(error as NSError)
})
.disposed(by: disposeBag)
} else {
self.toTextField.text = "Invalid Input!"
}
Example Usages
Currently, the library features the following extensions:
let stringURL = ""
// MARK: URLSession simple and fast
let session = URLSession.shared()
_ = session.rx
.response(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
_ = session.rx
.json(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
_ = session.rx
.data(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// MARK: With Alamofire engine
_ = json(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// validation
_ = request(.get, stringURL)
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.responseJSON()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// progress
_ = request(.get, stringURL)
.progress()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// just fire upload and display progress
_ = upload(Data(), urlRequest: try! RxAlamofire.urlRequest(.get, stringURL))
.progress()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// progress and final result
// uploading files with progress showing is processing intensive operation anyway, so
// this doesn't add much overhead
_ = request(.get, stringURL)
.flatMap { request -> Observable<(Data?, RxProgress)> in
let dataPart = request.rx
.data()
.map { d -> Data? in d }
.startWith(nil as Data?)
let progressPart = request.rx.progress()
return Observable.combineLatest(dataPart, progressPart) { ($0, $1) }
}
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// MARK: Alamofire Session
// same methods with any Alamofire Session
let session = Session.default
// simple case
_ = session.rx.json(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// URLHTTPResponse + JSON
_ = session.rx.responseJSON(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// URLHTTPResponse + String
_ = session.rx.responseString(.get, stringURL)
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// URLHTTPResponse + Validation + JSON
_ = session.rx.request(.get, stringURL)
.validate(statusCode: 200 ..< 300)
.validate(contentType: ["text/json"])
.json()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// URLHTTPResponse + Validation + URLHTTPResponse + JSON
_ = session.rx.request(.get, stringURL)
.validate(statusCode: 200 ..< 300)
.validate(contentType: ["text/json"])
.responseJSON()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// URLHTTPResponse + Validation + URLHTTPResponse + String + Progress
_ = session.rx.request(.get, stringURL)
.validate(statusCode: 200 ..< 300)
.validate(contentType: ["text/something"])
.flatMap { request -> Observable<(String?, RxProgress)> in
let stringPart = request.rx
.string()
.map { d -> String? in d }
.startWith(nil as String?)
let progressPart = request.rx.progress()
return Observable.combineLatest(stringPart, progressPart) { ($0, $1) }
}
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
// Interceptor + URLHTTPResponse + Validation + JSON
let adapter = // Some RequestAdapter
let retrier = // Some RequestRetrier
let interceptor = Interceptor(adapter: adapter, retrier: retrier)
_ = session.rx.request(.get, stringURL)
.validate()
.validate(contentType: ["text/json"])
.responseJSON()
.observeOn(MainScheduler.instance)
.subscribe { print($0) }
Installation
There are three ways to install RxAlamofire
CocoaPods
Just add to your project's Podfile
:
pod 'RxAlamofire'
Carthage
Add following to Cartfile
:
github "RxSwiftCommunity/RxAlamofire" ~> 6.1
Swift Package manager
Create a Package.swift
file
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "TestRxAlamofire",
dependencies: [
.package(url: "https://github.com/RxSwiftCommunity/RxAlamofire.git",
from: "6.1.0"),
],
targets: [
.target(
name: "TestRxAlamofire",
dependencies: ["RxAlamofire"])
]
)
Manually
To manual install this extension you should get the RxAlamofire/Source/RxAlamofire.swift
imported into your project, alongside RxSwift and Alamofire.
Requirements
RxAlamofire requires Swift 5.1 and dedicated versions of Alamofire (5.4.1) and RxSwift (6.0.0).
For the last RxSwift 5.1 support, please use RxAlamofire 5.7.1.
For the last Swift 5.0 support, please use RxAlamofire 5.1.0.
For the last Swift 4.2 support, please use RxAlamofire 4.5.0.
*Note that all licence references and agreements mentioned in the RxAlamofire README section above
are relevant to that project's source code only.