New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds support for CocoaPods and Swift PM #12
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.0 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'cocoapods', '~> 1.2.0' | ||
gem 'cocoapods-keys' | ||
gem 'xcpretty' | ||
gem 'xcodeproj' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
CFPropertyList (2.3.5) | ||
RubyInline (3.12.4) | ||
ZenTest (~> 4.3) | ||
ZenTest (4.11.1) | ||
activesupport (4.2.7.1) | ||
i18n (~> 0.7) | ||
json (~> 1.7, >= 1.7.7) | ||
minitest (~> 5.1) | ||
thread_safe (~> 0.3, >= 0.3.4) | ||
tzinfo (~> 1.1) | ||
claide (1.0.1) | ||
cocoapods (1.2.0) | ||
activesupport (>= 4.0.2, < 5) | ||
claide (>= 1.0.1, < 2.0) | ||
cocoapods-core (= 1.2.0) | ||
cocoapods-deintegrate (>= 1.0.1, < 2.0) | ||
cocoapods-downloader (>= 1.1.3, < 2.0) | ||
cocoapods-plugins (>= 1.0.0, < 2.0) | ||
cocoapods-search (>= 1.0.0, < 2.0) | ||
cocoapods-stats (>= 1.0.0, < 2.0) | ||
cocoapods-trunk (>= 1.1.2, < 2.0) | ||
cocoapods-try (>= 1.1.0, < 2.0) | ||
colored (~> 1.2) | ||
escape (~> 0.0.4) | ||
fourflusher (~> 2.0.1) | ||
gh_inspector (~> 1.0) | ||
molinillo (~> 0.5.5) | ||
nap (~> 1.0) | ||
ruby-macho (~> 0.2.5) | ||
xcodeproj (>= 1.4.1, < 2.0) | ||
cocoapods-core (1.2.0) | ||
activesupport (>= 4.0.2, < 5) | ||
fuzzy_match (~> 2.0.4) | ||
nap (~> 1.0) | ||
cocoapods-deintegrate (1.0.1) | ||
cocoapods-downloader (1.1.3) | ||
cocoapods-keys (2.0.0) | ||
dotenv | ||
osx_keychain | ||
cocoapods-plugins (1.0.0) | ||
nap | ||
cocoapods-search (1.0.0) | ||
cocoapods-stats (1.0.0) | ||
cocoapods-trunk (1.1.2) | ||
nap (>= 0.8, < 2.0) | ||
netrc (= 0.7.8) | ||
cocoapods-try (1.1.0) | ||
colored (1.2) | ||
dotenv (2.2.0) | ||
escape (0.0.4) | ||
fourflusher (2.0.1) | ||
fuzzy_match (2.0.4) | ||
gh_inspector (1.0.3) | ||
i18n (0.8.0) | ||
json (1.8.6) | ||
minitest (5.10.1) | ||
molinillo (0.5.6) | ||
nanaimo (0.2.3) | ||
nap (1.1.0) | ||
netrc (0.7.8) | ||
osx_keychain (1.0.1) | ||
RubyInline (~> 3) | ||
rouge (1.11.1) | ||
ruby-macho (0.2.6) | ||
thread_safe (0.3.5) | ||
tzinfo (1.2.2) | ||
thread_safe (~> 0.1) | ||
xcodeproj (1.4.2) | ||
CFPropertyList (~> 2.3.3) | ||
activesupport (>= 3) | ||
claide (>= 1.0.1, < 2.0) | ||
colored (~> 1.2) | ||
nanaimo (~> 0.2.3) | ||
xcpretty (0.2.4) | ||
rouge (~> 1.8) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
cocoapods (~> 1.2.0) | ||
cocoapods-keys | ||
xcodeproj | ||
xcpretty | ||
|
||
BUNDLED WITH | ||
1.10.6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "Promise" | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "Promise" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you change the to |
||
s.version = "2.0.0" | ||
s.summary = "A Promise library for Swift" | ||
s.description = "A Promise library for Swift, based partially on Javascript's A+ spec" | ||
s.module_name = "Promise" | ||
s.homepage = "https://github.com/khanlou/Promise" | ||
s.license = 'MIT' | ||
s.author = { "Soroush Khanlou" => "soroush@khanlou.com" } | ||
s.source = { :git => "https://github.com/khanlou/Promise.git", :tag => "2.0.0" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you update the tag to |
||
s.social_media_url = 'https://twitter.com/khanlou' | ||
s.source_files = 'Sources/*.swift' | ||
s.cocoapods_version = '>= 1.0' | ||
s.ios.deployment_target = '9.0' | ||
s.osx.deployment_target = '10.11' | ||
s.frameworks = 'Foundation' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,16 +18,52 @@ Using a special type to represent values that will exist in the future means tha | |
|
||
Promises are suited for any asynchronous action that can succeed or fail exactly once, such as HTTP requests. If there is an asynchronous action that can "succeed" more than once, or delivers a series of values over time instead of just one, take a look at [Signals](https://github.com/JensRavens/Interstellar/) or [Observables](https://github.com/ReactiveX/RxSwift). | ||
|
||
## Basic Usage | ||
## Installation | ||
|
||
To access the value once it arrives, you call the `then` method with a block. | ||
### [CocoaPods](http://cocoapods.org/) | ||
|
||
1. Add the following to your [Podfile](http://guides.cocoapods.org/using/the-podfile.html): | ||
|
||
```rb | ||
pod 'Promise' | ||
``` | ||
|
||
2. Integrate your dependencies using frameworks: add `use_frameworks!` to your Podfile. | ||
3. Run `pod install`. | ||
|
||
### [Carthage](https://github.com/Carthage/Carthage) | ||
|
||
1. Add the following to your [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile): | ||
|
||
``` | ||
github "khanlou/Promise" | ||
``` | ||
|
||
2. Run `carthage update` and follow the steps as described in Carthage's [README](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application). | ||
|
||
### [Swift Package Manager](https://swift.org/package-manager/) | ||
|
||
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. It is in early development, but Promise does support its use on supported platforms. | ||
|
||
Once you have your Swift package set up, adding AlamPromiseofire as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. | ||
|
||
```swift | ||
let usersPromise = fetchUsers() // Promise<[User]> | ||
usersPromise.then({ users in | ||
self.users = users | ||
}) | ||
dependencies: [ | ||
.Package(url: "https://github.com/khanlou/Promise.git", majorVersion: 2) | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think installation instructions should go at the end of the README. ime people have more problems understanding how they work than how to install a cocoapod. can you please update the cocoapod name here as well? |
||
``` | ||
|
||
## Basic Usage | ||
|
||
To access the value once it arrives, you call the `then` method with a block. | ||
|
||
```swift | ||
let usersPromise = fetchUsers() // Promise<[User]> | ||
usersPromise.then({ users in | ||
self.users = users | ||
}) | ||
``` | ||
|
||
All usage of the data in the `users` Promise is gated through the `then` method. | ||
|
||
In addition to performing side effects (like setting the `users` instance variable on `self`), `then` enables you do two other things. First, you can transform the contents of the Promise, and second, you can kick off another Promise, to do more asynchronous work. To do either of these things, return something from the block you pass to `then`. Each time you call `then`, the existing Promise will return a new Promise. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be 3.1 now?