Permalink
Browse files

5.0.0

  • Loading branch information...
mxcl committed Aug 7, 2017
1 parent ac79c48 commit 47367f1df656bf8e976e28fb59e553639efcf73a
Showing with 1,790 additions and 2,608 deletions.
  1. +1 −1 Extensions/AVFoundation
  2. +1 −1 Extensions/Accounts
  3. +1 −1 Extensions/AddressBook
  4. +1 −1 Extensions/Alamofire
  5. +1 −1 Extensions/AssetsLibrary
  6. +1 −1 Extensions/Bolts
  7. +1 −1 Extensions/CloudKit
  8. +1 −1 Extensions/CoreBluetooth
  9. +1 −1 Extensions/CoreLocation
  10. +1 −1 Extensions/EventKit
  11. +1 −1 Extensions/Foundation
  12. +1 −1 Extensions/MapKit
  13. +1 −1 Extensions/MessagesUI
  14. +1 −1 Extensions/OMGHTTPURLRQ
  15. +1 −1 Extensions/Photos
  16. +1 −1 Extensions/QuartzCore
  17. +1 −1 Extensions/Social
  18. +1 −1 Extensions/StoreKit
  19. +1 −1 Extensions/SystemConfiguration
  20. +1 −1 Extensions/UIKit
  21. +1 −1 Extensions/WatchConnectivity
  22. +5 −7 PromiseKit.playground/Contents.swift
  23. +5 −2 PromiseKit.podspec
  24. +90 −102 PromiseKit.xcodeproj/project.pbxproj
  25. +1 −1 PromiseKit.xcodeproj/xcshareddata/xcschemes/PromiseKit.xcscheme
  26. +11 −7 README.md
  27. +1 −3 Sources/AnyPromise+Private.h
  28. +36 −60 Sources/AnyPromise.h
  29. +11 −25 Sources/AnyPromise.m
  30. +171 −190 Sources/AnyPromise.swift
  31. +96 −0 Sources/Box.swift
  32. +135 −0 Sources/Catchable.swift
  33. +13 −0 Sources/Configuration.swift
  34. +26 −0 Sources/CustomStringConvertible.swift
  35. +0 −53 Sources/DispatchQueue+Promise.swift
  36. +38 −134 Sources/Error.swift
  37. +0 −76 Sources/GlobalState.m
  38. +145 −0 Sources/Guarantee.swift
  39. +7 −1 Sources/PMKCallVariadicBlock.m
  40. +0 −41 Sources/Promise+AnyPromise.swift
  41. +0 −57 Sources/Promise+Properties.swift
  42. +92 −584 Sources/Promise.swift
  43. +77 −0 Sources/Resolver.swift
  44. +0 −219 Sources/State.swift
  45. +0 −16 Sources/SwiftPM.swift
  46. +226 −0 Sources/Thenable.swift
  47. +0 −80 Sources/Zalgo.swift
  48. +23 −22 Sources/after.swift
  49. +37 −0 Sources/firstly.swift
  50. +0 −79 Sources/fwd.h
  51. +1 −1 Sources/hang.m
  52. +0 −60 Sources/join.swift
  53. +34 −14 Sources/race.swift
  54. +66 −64 Sources/when.swift
  55. +0 −79 Sources/wrap.swift
  56. +14 −11 Tests/A+/0.0.0.swift
  57. +2 −2 Tests/A+/2.1.2.swift
  58. +3 −3 Tests/A+/2.1.3.swift
  59. +22 −22 Tests/A+/2.2.2.swift
  60. +11 −11 Tests/A+/2.2.4.swift
  61. +62 −58 Tests/A+/2.2.6.swift
  62. +2 −2 Tests/A+/2.2.7.swift
  63. +8 −8 Tests/A+/2.3.2.swift
  64. +5 −5 Tests/A+/2.3.4.swift
  65. +1 −2 Tests/Bridging/BridgingTests.m
  66. +29 −23 Tests/Bridging/BridgingTests.swift
  67. +5 −5 Tests/Bridging/Infrastructure.swift
  68. +9 −20 Tests/CorePromise/01_AnyPromiseTests.m
  69. +29 −17 Tests/CorePromise/01_PromiseTests.swift
  70. +51 −66 Tests/CorePromise/02_CancellationTests.swift
  71. +0 −132 Tests/CorePromise/02_ErrorUnhandlerTests.m
  72. +14 −14 Tests/CorePromise/02_ZalgoTests.swift
  73. +9 −21 Tests/CorePromise/03_AfterTests.swift
  74. +20 −12 Tests/CorePromise/03_JoinTests.swift
  75. +7 −5 Tests/CorePromise/03_RaceTests.swift
  76. +18 −25 Tests/CorePromise/03_WhenConcurrentTests.swift
  77. +33 −41 Tests/CorePromise/03_WhenTests.swift
  78. +20 −17 Tests/CorePromise/03_WrapTests.swift
  79. +0 −28 Tests/CorePromise/04_VerifySubclassing.swift
  80. +10 −11 Tests/CorePromise/98_StressTests.swift
  81. +4 −4 Tests/CorePromise/99_RegressionTests.swift
  82. +32 −0 Tests/CorePromise/CatchableTests.swift
  83. +0 −11 Tests/CorePromise/Infrastructure.h
  84. +0 −16 Tests/CorePromise/Infrastructure.m
  85. +0 −16 Tests/CorePromise/Infrastructure.swift
  86. +2 −2 Tests/CorePromise/PMKDefaultDispatchQueueTest.swift
@@ -7,21 +7,19 @@ import PromiseKit
func promise3() -> Promise<Int> {
return after(seconds: 1).then {
return 3
}
return after(.seconds(1)).map{ 3 }
}
firstly {
Promise(value: 1)
}.then { _ in
}.map { _ in
2
}.then { _ in
promise3()
}.then {
}.done {
print($0) // => 3
}.always {
// always happens
}.ensure {
PlaygroundPage.current.finishExecution()
}.catch { error in
// only happens for errors
}
View
@@ -3,7 +3,6 @@ Pod::Spec.new do |s|
`xcodebuild -project PromiseKit.xcodeproj -showBuildSettings` =~ /CURRENT_PROJECT_VERSION = ((\d\.)+\d)/
abort("No version detected") if $1.nil?
abort("Not tagged") unless `git tag`.split.include? $1
s.version = $1
s.source = {
@@ -19,7 +18,7 @@ Pod::Spec.new do |s|
s.social_media_url = 'https://twitter.com/mxcl'
s.authors = { 'Max Howell' => 'mxcl@me.com' }
s.documentation_url = 'http://promisekit.org/docs/'
s.default_subspecs = 'Foundation', 'UIKit', 'QuartzCore'
s.default_subspecs = 'CorePromise'
s.requires_arc = true
# CocoaPods requires us to specify the root deployment targets
@@ -29,6 +28,10 @@ Pod::Spec.new do |s|
s.osx.deployment_target = '10.11'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => '-DPMKCocoaPods',
}
s.subspec 'Accounts' do |ss|
ss.ios.source_files = ss.osx.source_files = 'Extensions/Accounts/Sources/*'

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
View
@@ -41,11 +41,15 @@ target "Change Me!" do
end
```
PromiseKit 4 supports Xcode 8.1, 8.2, 8.3 and 9.0; Swift 3.0, 3.1, 3.2 and 4.0; iOS, macOS, tvOS, watchOS, Linux and Android; CocoaPods, Carthage and SwiftPM; ([CI Matrix](https://travis-ci.org/mxcl/PromiseKit)).
PromiseKit 4 and 5 support Xcode 8.1, 8.2, 8.3 and 9.0; Swift 3.0, 3.1, 3.2 and 4.0; iOS, macOS, tvOS, watchOS, Linux and Android; CocoaPods, Carthage and SwiftPM; ([CI Matrix](https://travis-ci.org/mxcl/PromiseKit)).
For Carthage, SwiftPM, etc., or for instructions when using older Swifts or
Xcodes see our [Installation Guide](Documentation/Installation.md).
# PromiseKit 5
PromiseKit 5 has been released, but is not yet fully documented, so we advise sticking with version 4 for the time being.
# Documentation
* Handbook
@@ -64,13 +68,13 @@ If you are looking for a function’s documentation, then please note
# Extensions
Promises are only as useful as the asynchronous tasks they represent, thus we
have converted (almost) all of Apple’s APIs to promises. The default CocoaPod
comes with promises for UIKit and Foundation, the rest can be installed by
specifying additional subspecs in your `Podfile`, eg:
have converted (almost) all of Apple’s APIs to promises. By default PromiseKit
only provides promises, the extensions are available by specifying additional
subspecs in your `Podfile`, eg:
```ruby
pod "PromiseKit/MapKit" # MKDirections().promise().then { /*…*/ }
pod "PromiseKit/CoreLocation" # CLLocationManager.promise().then { /*…*/ }
pod "PromiseKit/MapKit" # MKDirections().calculate().then { /*…*/ }
pod "PromiseKit/CoreLocation" # CLLocationManager.requestLocation().then { /*…*/ }
```
All our extensions are separate repositories at the [PromiseKit organization].
@@ -107,7 +111,7 @@ URLSession.shared.dataTask(url).asDictionary().then { json in
```
Nobody ever got fired for using Alamofire, but at the end of the day, it’s
just a small wrapper around `NSURLSession`. OMGHTTPURLRQ supplements
just a wrapper around `NSURLSession`. OMGHTTPURLRQ supplements
`NSURLRequest` to make generating REST style requests easier, and the PromiseKit
extensions extend `NSURLSession` to make OMG usage more convenient. But since a
while now most servers accept JSON, so writing a simple API class that uses
@@ -27,12 +27,10 @@
@interface AnyPromise (Swift)
- (AnyPromise * __nonnull)__thenOn:(__nonnull dispatch_queue_t)q execute:(id __nullable (^ __nonnull)(id __nullable))body;
- (AnyPromise * __nonnull)__catchOn:(__nonnull dispatch_queue_t)q withPolicy:(PMKCatchPolicy)policy execute:(id __nullable (^ __nonnull)(id __nullable))body;
- (AnyPromise * __nonnull)__catchOn:(__nonnull dispatch_queue_t)q execute:(id __nullable (^ __nonnull)(id __nullable))body;
- (AnyPromise * __nonnull)__alwaysOn:(__nonnull dispatch_queue_t)q execute:(void (^ __nonnull)(void))body;
- (void)__pipe:(void(^ __nonnull)(__nullable id))body;
- (AnyPromise * __nonnull)initWithResolverBlock:(void (^ __nonnull)(PMKResolver __nonnull))resolver;
@end
extern NSError * __nullable PMKProcessUnhandledException(id __nonnull thrown);
@class PMKArray;
View
@@ -4,12 +4,6 @@
typedef void (^PMKResolver)(id __nullable) NS_REFINED_FOR_SWIFT;
typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
PMKCatchPolicyAllErrors,
PMKCatchPolicyAllErrorsExceptCancellation
} NS_SWIFT_NAME(CatchPolicy);
#if __has_include("PromiseKit-Swift.h")
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wdocumentation"
@@ -23,18 +17,30 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
__attribute__((objc_subclassing_restricted)) __attribute__((objc_runtime_name("AnyPromise")))
@interface AnyPromise : NSObject
@property (nonatomic, readonly) BOOL resolved;
@property (nonatomic, readonly) BOOL pending;
@property (nonatomic, readonly) __nullable id value;
+ (instancetype __nonnull)promiseWithResolverBlock:(void (^ __nonnull)(__nonnull PMKResolver))resolveBlock;
+ (instancetype __nonnull)promiseWithValue:(__nullable id)value;
+ (instancetype __nonnull)promiseWithResolverBlock:(void (^ __nonnull)(__nonnull PMKResolver))resolveBlock NS_REFINED_FOR_SWIFT;
+ (instancetype __nonnull)promiseWithValue:(__nullable id)value NS_REFINED_FOR_SWIFT;
@end
#endif
@interface AnyPromise (obj)
@property (nonatomic, readonly) __nullable id value;
/**
The value of the asynchronous task this promise represents.
A promise has `nil` value if the asynchronous task it represents has not finished. If the value is `nil` the promise is still `pending`.
- Warning: *Note* Our Swift variant’s value property returns nil if the promise is rejected where AnyPromise will return the error object. This fits with the pattern where AnyPromise is not strictly typed and is more dynamic, but you should be aware of the distinction.
- Note: If the AnyPromise was fulfilled with a `PMKManifold`, returns only the first fulfillment object.
- Returns: The value with which this promise was resolved or `nil` if this promise is pending.
*/
@property (nonatomic, readonly) __nullable id value NS_REFINED_FOR_SWIFT;
/// - Returns: if the promise is pending resolution.
@property (nonatomic, readonly) BOOL pending NS_REFINED_FOR_SWIFT;
/**
The provided block is executed when its receiver is resolved.
@@ -93,9 +99,10 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
@warning *Note* Cancellation errors are not caught.
@warning *Note* Since catch is a c++ keyword, this method is not available in Objective-C++ files. Instead use catchWithPolicy.
@warning *Note* Since catch is a c++ keyword, this method is not available in Objective-C++ files. Instead use catchOn.
@see catchWithPolicy
@see catchOn
@see catchInBackground
*/
- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))catch NS_REFINED_FOR_SWIFT;
#endif
@@ -111,7 +118,8 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
@warning *Note* Since catch is a c++ keyword, this method is not available in Objective-C++ files. Instead use catchWithPolicy.
@see catchWithPolicy
@see catch
@see catchOn
*/
- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))catchInBackground NS_REFINED_FOR_SWIFT;
@@ -125,50 +133,26 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
@warning *Note* Cancellation errors are not caught.
@see catchWithPolicy
*/
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, id __nonnull))catchOn NS_REFINED_FOR_SWIFT;
/**
The provided block is executed when the receiver is rejected with the specified policy.
Specify the policy with which to catch as the first parameter to your block. Either for all errors, or all errors *except* cancellation errors.
@see catch
*/
- (AnyPromise * __nonnull(^ __nonnull)(PMKCatchPolicy, id __nonnull))catchWithPolicy NS_REFINED_FOR_SWIFT;
/**
The provided block is executed when the receiver is rejected with the specified policy.
Specify the policy with which to catch as the first parameter to your block. Either for all errors, or all errors *except* cancellation errors.
The provided block always runs on queue provided.
@see catch
@see catchInBackground
*/
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, PMKCatchPolicy, id __nonnull))catchOnWithPolicy NS_REFINED_FOR_SWIFT;
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, id __nonnull))catchOn NS_REFINED_FOR_SWIFT;
/**
The provided block is executed when the receiver is resolved.
The provided block always runs on the main queue.
@see alwaysOn
@see ensureOn
*/
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))always NS_REFINED_FOR_SWIFT;
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))ensure NS_REFINED_FOR_SWIFT;
/**
The provided block is executed on the dispatch queue of your choice when the receiver is resolved.
@see always
@see ensure
*/
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, dispatch_block_t __nonnull))alwaysOn NS_REFINED_FOR_SWIFT;
/// @see always
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))finally __attribute__((deprecated("Use always")));
/// @see alwaysOn
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull, dispatch_block_t __nonnull))finallyOn __attribute__((deprecated("Use always")));
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, dispatch_block_t __nonnull))ensureOn NS_REFINED_FOR_SWIFT;
/**
Create a new promise with an associated resolver.
@@ -197,16 +181,6 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
@end
@interface AnyPromise (Unavailable)
- (instancetype __nonnull)init __attribute__((unavailable("It is illegal to create an unresolvable promise.")));
+ (instancetype __nonnull)new __attribute__((unavailable("It is illegal to create an unresolvable promise.")));
@end
typedef void (^PMKAdapter)(id __nullable, NSError * __nullable) NS_REFINED_FOR_SWIFT;
typedef void (^PMKIntegerAdapter)(NSInteger, NSError * __nullable) NS_REFINED_FOR_SWIFT;
typedef void (^PMKBooleanAdapter)(BOOL, NSError * __nullable) NS_REFINED_FOR_SWIFT;
@@ -281,15 +255,17 @@ extern id __nonnull __PMKArrayWithCount(NSUInteger, ...);
#endif
@interface AnyPromise (Deprecations)
@interface AnyPromise (Unavailable)
+ (instancetype __nonnull)new:(__nullable id)resolvers __attribute__((unavailable("See +promiseWithResolverBlock:")));
+ (instancetype __nonnull)when:(__nullable id)promises __attribute__((unavailable("See PMKWhen()")));
+ (instancetype __nonnull)join:(__nullable id)promises __attribute__((unavailable("See PMKJoin()")));
- (instancetype __nonnull)init __attribute__((unavailable("It is illegal to create an unresolvable promise.")));
+ (instancetype __nonnull)new __attribute__((unavailable("It is illegal to create an unresolvable promise.")));
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))always __attribute__((unavailable("See -ensure")));
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))alwaysOn __attribute__((unavailable("See -ensureOn")));
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))finally __attribute__((unavailable("See -ensure")));
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull, dispatch_block_t __nonnull))finallyOn __attribute__((unavailable("See -ensureOn")));
@end
__attribute__((unavailable("See AnyPromise")))
@interface PMKPromise
@end
Oops, something went wrong.

0 comments on commit 47367f1

Please sign in to comment.