Future alternatives and similar libraries
Based on the "Events" category.
Alternatively, view Future alternatives based on common mentions on social networks and blogs.
-
ReactiveCocoa
Cocoa framework and Obj-C dynamism bindings for ReactiveSwift. -
ReactorKit
A library for reactive and unidirectional Swift applications -
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. -
BrightFutures
Write great asynchronous code in Swift using futures and promises -
PMKVObserver
Modern thread-safe and type-safe key-value observing for Swift and Objective-C -
Tempura
A holistic approach to iOS development, inspired by Redux and MVVM -
VueFlux
:recycle: Unidirectional State Management Architecture for Swift - Inspired by Vuex and Flux -
SignalKit
SignalKit is a reactive Swift framework with focus on clean and readable API. -
NoticeObserveKit
NoticeObserveKit is type-safe NotificationCenter wrapper. -
LightweightObservable
📬 A lightweight implementation of an observable sequence that you can subscribe to. -
RxReduce
Reactive implementation of the state container pattern (like Redux). It is based on the simple concepts of state immutability and unidirectionnal data flow. -
Aftermath
:crystal_ball: Stateless message-driven micro-framework in Swift. -
TopicEventBus
Publish–subscribe design pattern implementation framework, with an ability to publish events by topic. -
OneWay
A Swift library for state management with unidirectional data flow. -
SSEventFlow
SSEventFlow is a type safe alternative to NotificationCenter, inspired by Flux -
Causality
A simple thread-safe, in-memory bus for Swift that supports fully-typed Events and States.
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 Future or a related project?
README
Future
Swift µframework providing Future<T, Error>.
This library is inspired by the talk of Javier Soto at SwiftSubmit2015 and the Future
implementation in Scala.
And this is using antitypical/Result
.
Why we need Future?
Traditional async code
func requestRepository(repoId: Int64, completion: (Repository?, NSError?) -> Void) {}
func requestUser(userId: Int64, completion: (User?, NSError?) -> Void) {}
// get owner info of a given repository
requestRepository(12345) { repo, error in
if let repo = repo {
requestUser(repo.ownerId) { user, error in
if let user = user {
// do something
} else {
// error handling
}
}
} else {
// error handling
}
}
Code with Future
let future = requestRepository(12345)
.map { $0.ownerId }
.flatMap(requestUser)
future.onCompleted { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
Shorthand by using operator
let future = requestRepository(12345) <^> { $0.ownerId } >>- requestUser
future.onCompleted { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
Usage
map
<^>
let f = requestUser("nghialv") <^> { $0.id }
f.onSuccess { userId in
println(userId)
}
flatMap
>>-
let f = searchRepositories("Hakuba") <^> { $0.first!.ownerName } >>- requestUser
f.onComplete { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
filter
let e = NSError(domain: "noSuchElement", code: 1, userInfo: nil)
let f1 = searchRepositories("Hakuba")
let f = f1.filter(e){ $0.count > 0 } <^> { $0.first!.ownerName } >>- requestUser
f.onComplete { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
andThen
// side-effect
var reposCount = 0
let f1 = searchRepositories("Hakuba")
let f2 = f1.andThen { result in
switch result {
case .Success(let repos): reposCount = repos.value.count
case .Failure(let error): break
}
}
let f3 = f2 <^> { $0.first!.ownerName } >>- requestUser
f3.onComplete { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
recover
zip
let f1 = searchRepositories("Future")
let f2 = requestUser("nghialv")
let f3 = f1.zip(f2)
f3.onSuccess { repos, user in
println(repos)
println(user)
}
flatten
Installation
Using Carthage
- Insert
github "nghialv/Future"
to your Cartfile - Run
carthage update
- Insert
Using Cocoapods
- Insert
use_frameworks!
to your Podfile - Insert
pod "Future"
to your Podfile - Run
pod install
- Insert
Using Submodule
Requirements
- Swift 1.2 (Xcode 6.3 or later)
- iOS 8.0 or later
*Note that all licence references and agreements mentioned in the Future README section above
are relevant to that project's source code only.