Latest | 0.1.0 |
---|---|
Homepage | https://github.com/TangentW/Deferred |
License | MIT |
Platforms | osx , ios , tvos , watchos |
Authors |
Deferred
Introduction
A little Functional
& Reactive
programming library.
Installation
Cocoapods
Add TanDeferred
in your Podfile
:
use_frameworks!
pod "TanDeferred"
Then run the following command:
$ pod install
Manually
- Download the source code.
- Drag folder Deferred/Deferred into your project.
Usage
Basic usage
// Create an instance of Deferred
Deferred *deferred = [Deferred deferred];
// Subscribe
[deferred subscribe:^(id _Nullable value) {
NSLog(@"%@", value);
}];
// Just fill it
[deferred fill:@"Hello World"];
Or you can create with an initialized value:
Deferred *deferred = [Deferred just:@"Hello World"];
Map & FlatMap
[[[deferred map:^id _Nullable(id _Nullable value) {
return [value stringByAppendingString:@"Good morning"];
}] flatMap:^Deferred * _Nonnull(id _Nullable value) {
return [Deferred just:[value stringByAppendingString:@"Good night"]];
}] subscribe:^(id _Nullable value) {
NSLog(@"%@", value);
}];
Multi-thread
There are four
queues to control Deferred
to execute missions with multi-thread
:
- MainQueue
- SyncQueue (Default)
- AsyncQueue
- CustomQueue
[[deferred mapOn:[AsyncQueue shared] with:^id _Nullable(id _Nullable value) {
return [value stringByAppendingString:@"Baby"];
}] subscribeOn:[MainQueue shared] with:^(id _Nullable value) {
NSLog(@"%@", value);
}];
License
The MIT License (MIT)
Latest podspec
{ "name": "TanDeferred", "version": "0.1.0", "summary": "A little `Functional` & `Reactive` programming library.", "homepage": "https://github.com/TangentW/Deferred", "license": { "type": "MIT", "file": "LICENSE" }, "authors": { "Tangent": "[email protected]" }, "source": { "git": "https://github.com/TangentW/Deferred.git", "tag": "0.1.0" }, "source_files": "Deferred/Deferred/**/*.{h,m}", "platforms": { "osx": null, "ios": null, "tvos": null, "watchos": null } }
Fri, 15 Dec 2017 11:40:29 +0000