Nifty is a library of asynchronous utilities for everyday programmers.
- Streams (based on Java 8)
- Channels (based loosely on Go)
- Futures / Promises
- Continuation monad
- Either enum
Nifty's concurrency is implemented via DispatchKit.
(1..<100).stream()
.map { $0 * 2 }
.flatMap { ($0..<100).stream() }
.reduce(0, combine: +) // Run asynchronously. Returns Future
.onComplete { print($0) }
Use streams to get seamless concurrent and lazy composition of data.
Use futures to easily perform operations asynchronously, without callback hell.
Channels allow you to easily receive data from other threads.