Skip to content

Commit 05a4dc7

Browse files
committed
5.0.0-alpha4
1 parent 1c37c08 commit 05a4dc7

16 files changed

+726
-169
lines changed

Extensions/Alamofire

Extensions/UIKit

PromiseKit.xcodeproj/project.pbxproj

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
631751C01D59768200A9DDDC /* 2.3.2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 631751B41D59768200A9DDDC /* 2.3.2.swift */; };
2525
631751C11D59768200A9DDDC /* 2.3.4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 631751B51D59768200A9DDDC /* 2.3.4.swift */; };
2626
631F443A1E381B640044C63C /* Sealant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 631F44391E381B640044C63C /* Sealant.swift */; };
27-
635D64231D59635300BC0AF5 /* AfterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635D640E1D59635300BC0AF5 /* AfterTests.swift */; };
28-
635D64271D59635300BC0AF5 /* RaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635D64121D59635300BC0AF5 /* RaceTests.swift */; };
27+
632714CF1E4D08C20043BBB2 /* Fundamentals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 632714CD1E4D082D0043BBB2 /* Fundamentals.swift */; };
2928
635D642B1D59635300BC0AF5 /* StressTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635D64161D59635300BC0AF5 /* StressTests.swift */; };
3029
635D642C1D59635300BC0AF5 /* RegressionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 635D64171D59635300BC0AF5 /* RegressionTests.swift */; };
3130
635D64301D596E8500BC0AF5 /* PromiseKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63B0AC571D595E1B00FA21D9 /* PromiseKit.framework */; };
31+
63611ADE1E4D6CD40031BD6C /* AnyPromise.m in Sources */ = {isa = PBXBuildFile; fileRef = 63611ADD1E4D6CD40031BD6C /* AnyPromise.m */; };
32+
63611AE01E4D6E280031BD6C /* AnyPromise.h in Headers */ = {isa = PBXBuildFile; fileRef = 63611ADF1E4D6E280031BD6C /* AnyPromise.h */; settings = {ATTRIBUTES = (Public, ); }; };
33+
6375053F1E4E1D3100DE318B /* Features.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6375053D1E4E1C8600DE318B /* Features.swift */; };
3234
639F72DD1E38160C00F08DD5 /* firstly.swift in Sources */ = {isa = PBXBuildFile; fileRef = 639F72DC1E38160C00F08DD5 /* firstly.swift */; };
3335
63B0AC801D595E6300FA21D9 /* after.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63B0AC621D595E6300FA21D9 /* after.swift */; };
3436
63B0AC871D595E6300FA21D9 /* Error.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63B0AC691D595E6300FA21D9 /* Error.swift */; };
@@ -57,7 +59,7 @@
5759
/* Begin PBXFileReference section */
5860
49A5584B1DC5172F00E4D01B /* WrapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WrapTests.swift; path = Tests/CorePromise/WrapTests.swift; sourceTree = "<group>"; };
5961
630019221D596292003B4E30 /* PMKCoreTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PMKCoreTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
60-
630F217C1E3FE84A00F6DB1E /* Promise+deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Promise+deprecations.swift"; sourceTree = "<group>"; };
62+
630F217C1E3FE84A00F6DB1E /* Promise+deprecations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Promise+deprecations.swift"; path = "Sources/Promise+deprecations.swift"; sourceTree = "<group>"; };
6163
630F217E1E3FF68A00F6DB1E /* Infrastructure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Infrastructure.swift; path = Tests/Infrastructure.swift; sourceTree = "<group>"; };
6264
631751A81D59766500A9DDDC /* PMKA+Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "PMKA+Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
6365
631751AB1D59768200A9DDDC /* 0.0.0.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 0.0.0.swift; sourceTree = "<group>"; };
@@ -72,17 +74,19 @@
7274
631751B41D59768200A9DDDC /* 2.3.2.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 2.3.2.swift; sourceTree = "<group>"; };
7375
631751B51D59768200A9DDDC /* 2.3.4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 2.3.4.swift; sourceTree = "<group>"; };
7476
631751B61D59768200A9DDDC /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
75-
631F44391E381B640044C63C /* Sealant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sealant.swift; sourceTree = "<group>"; };
77+
631F44391E381B640044C63C /* Sealant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Sealant.swift; path = Sources/Sealant.swift; sourceTree = "<group>"; };
78+
632714CD1E4D082D0043BBB2 /* Fundamentals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Fundamentals.swift; path = Tests/CorePromise/Fundamentals.swift; sourceTree = "<group>"; };
7679
635893921D5BE4E000F14B55 /* PromiseKit.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = PromiseKit.playground; sourceTree = "<group>"; };
7780
635893931D5BE4F900F14B55 /* CHANGELOG.markdown */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.markdown; sourceTree = "<group>"; };
7881
635893941D5BE4F900F14B55 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
7982
635893951D5BE4F900F14B55 /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
8083
635893961D5BE4F900F14B55 /* PromiseKit.podspec */ = {isa = PBXFileReference; lastKnownFileType = text; path = PromiseKit.podspec; sourceTree = "<group>"; };
8184
635893971D5BE4F900F14B55 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.markdown; sourceTree = "<group>"; };
82-
635D640E1D59635300BC0AF5 /* AfterTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AfterTests.swift; path = Tests/CorePromise/AfterTests.swift; sourceTree = "<group>"; };
83-
635D64121D59635300BC0AF5 /* RaceTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RaceTests.swift; path = Tests/CorePromise/RaceTests.swift; sourceTree = "<group>"; };
8485
635D64161D59635300BC0AF5 /* StressTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StressTests.swift; path = Tests/CorePromise/StressTests.swift; sourceTree = "<group>"; };
8586
635D64171D59635300BC0AF5 /* RegressionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RegressionTests.swift; path = Tests/CorePromise/RegressionTests.swift; sourceTree = "<group>"; };
87+
63611ADD1E4D6CD40031BD6C /* AnyPromise.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AnyPromise.m; path = Sources/AnyPromise.m; sourceTree = "<group>"; };
88+
63611ADF1E4D6E280031BD6C /* AnyPromise.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnyPromise.h; path = Sources/AnyPromise.h; sourceTree = "<group>"; };
89+
6375053D1E4E1C8600DE318B /* Features.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Features.swift; path = Tests/CorePromise/Features.swift; sourceTree = "<group>"; };
8690
639F72DC1E38160C00F08DD5 /* firstly.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = firstly.swift; path = Sources/firstly.swift; sourceTree = "<group>"; };
8791
63B0AC571D595E1B00FA21D9 /* PromiseKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PromiseKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8892
63B0AC621D595E6300FA21D9 /* after.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = after.swift; path = Sources/after.swift; sourceTree = "<group>"; };
@@ -123,11 +127,11 @@
123127
6317518A1D59765700A9DDDC /* Core */ = {
124128
isa = PBXGroup;
125129
children = (
126-
635D640E1D59635300BC0AF5 /* AfterTests.swift */,
127-
635D64121D59635300BC0AF5 /* RaceTests.swift */,
128-
49A5584B1DC5172F00E4D01B /* WrapTests.swift */,
130+
6375053D1E4E1C8600DE318B /* Features.swift */,
131+
632714CD1E4D082D0043BBB2 /* Fundamentals.swift */,
129132
635D64161D59635300BC0AF5 /* StressTests.swift */,
130133
635D64171D59635300BC0AF5 /* RegressionTests.swift */,
134+
49A5584B1DC5172F00E4D01B /* WrapTests.swift */,
131135
);
132136
name = Core;
133137
sourceTree = "<group>";
@@ -206,6 +210,7 @@
206210
63B0AC721D595E6300FA21D9 /* Promise.swift */,
207211
631F44391E381B640044C63C /* Sealant.swift */,
208212
630F217C1E3FE84A00F6DB1E /* Promise+deprecations.swift */,
213+
63611ADD1E4D6CD40031BD6C /* AnyPromise.m */,
209214
);
210215
name = Sources;
211216
sourceTree = "<group>";
@@ -223,6 +228,7 @@
223228
isa = PBXGroup;
224229
children = (
225230
63B0AC761D595E6300FA21D9 /* PromiseKit.h */,
231+
63611ADF1E4D6E280031BD6C /* AnyPromise.h */,
226232
);
227233
name = Headers;
228234
sourceTree = "<group>";
@@ -235,6 +241,7 @@
235241
buildActionMask = 2147483647;
236242
files = (
237243
63B0AC931D595E6300FA21D9 /* PromiseKit.h in Headers */,
244+
63611AE01E4D6E280031BD6C /* AnyPromise.h in Headers */,
238245
);
239246
runOnlyForDeploymentPostprocessing = 0;
240247
};
@@ -305,7 +312,7 @@
305312
};
306313
63B0AC561D595E1B00FA21D9 = {
307314
CreatedOnToolsVersion = 8.0;
308-
LastSwiftMigration = 0800;
315+
LastSwiftMigration = 0830;
309316
ProvisioningStyle = Automatic;
310317
};
311318
};
@@ -334,10 +341,10 @@
334341
isa = PBXSourcesBuildPhase;
335342
buildActionMask = 2147483647;
336343
files = (
344+
6375053F1E4E1D3100DE318B /* Features.swift in Sources */,
345+
632714CF1E4D08C20043BBB2 /* Fundamentals.swift in Sources */,
337346
630F21801E3FF68A00F6DB1E /* Infrastructure.swift in Sources */,
338-
635D64271D59635300BC0AF5 /* RaceTests.swift in Sources */,
339347
635D642B1D59635300BC0AF5 /* StressTests.swift in Sources */,
340-
635D64231D59635300BC0AF5 /* AfterTests.swift in Sources */,
341348
49A5584D1DC5185900E4D01B /* WrapTests.swift in Sources */,
342349
635D642C1D59635300BC0AF5 /* RegressionTests.swift in Sources */,
343350
);
@@ -372,6 +379,7 @@
372379
631F443A1E381B640044C63C /* Sealant.swift in Sources */,
373380
63E79EA51E16F86400D363A8 /* ExecutionContext.swift in Sources */,
374381
639F72DD1E38160C00F08DD5 /* firstly.swift in Sources */,
382+
63611ADE1E4D6CD40031BD6C /* AnyPromise.m in Sources */,
375383
63B0AC871D595E6300FA21D9 /* Error.swift in Sources */,
376384
);
377385
runOnlyForDeploymentPostprocessing = 0;
@@ -455,7 +463,7 @@
455463
CLANG_WARN_UNREACHABLE_CODE = YES;
456464
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
457465
COPY_PHASE_STRIP = NO;
458-
CURRENT_PROJECT_VERSION = "5.0.0-alpha3";
466+
CURRENT_PROJECT_VERSION = "5.0.0-alpha4";
459467
DEBUG_INFORMATION_FORMAT = dwarf;
460468
ENABLE_STRICT_OBJC_MSGSEND = YES;
461469
ENABLE_TESTABILITY = YES;
@@ -504,7 +512,7 @@
504512
CLANG_WARN_UNREACHABLE_CODE = YES;
505513
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
506514
COPY_PHASE_STRIP = NO;
507-
CURRENT_PROJECT_VERSION = "5.0.0-alpha3";
515+
CURRENT_PROJECT_VERSION = "5.0.0-alpha4";
508516
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
509517
ENABLE_NS_ASSERTIONS = NO;
510518
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -534,6 +542,7 @@
534542
isa = XCBuildConfiguration;
535543
buildSettings = {
536544
APPLICATION_EXTENSION_API_ONLY = YES;
545+
CLANG_ENABLE_MODULES = YES;
537546
CLANG_WARN_ASSIGN_ENUM = YES;
538547
CLANG_WARN_BOOL_CONVERSION = YES;
539548
CLANG_WARN_CONSTANT_CONVERSION = YES;
@@ -568,6 +577,8 @@
568577
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
569578
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
570579
SKIP_INSTALL = YES;
580+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
581+
SWIFT_VERSION = 3.0;
571582
TARGETED_DEVICE_FAMILY = "1,2,3,4";
572583
};
573584
name = Debug;
@@ -576,6 +587,7 @@
576587
isa = XCBuildConfiguration;
577588
buildSettings = {
578589
APPLICATION_EXTENSION_API_ONLY = YES;
590+
CLANG_ENABLE_MODULES = YES;
579591
CLANG_WARN_ASSIGN_ENUM = YES;
580592
CLANG_WARN_BOOL_CONVERSION = YES;
581593
CLANG_WARN_CONSTANT_CONVERSION = YES;
@@ -609,6 +621,7 @@
609621
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
610622
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
611623
SKIP_INSTALL = YES;
624+
SWIFT_VERSION = 3.0;
612625
TARGETED_DEVICE_FAMILY = "1,2,3,4";
613626
};
614627
name = Release;

Sources/AnyPromise.h

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#import <Foundation/Foundation.h>
2+
#import <PromiseKit/PromiseKit.h>
3+
4+
// exists to ease porting from PMK 4.x
5+
6+
typedef void (^PMKResolver)(id __nullable) NS_REFINED_FOR_SWIFT;
7+
8+
9+
#if __has_include("PromiseKit-Swift.h")
10+
11+
// we define this because PromiseKit-Swift.h imports
12+
// PromiseKit.h which then expects this header already
13+
// to have been fully imported… !
14+
@class AnyPromise;
15+
16+
#pragma clang diagnostic push
17+
#pragma clang diagnostic ignored"-Wdocumentation"
18+
#import "PromiseKit-Swift.h"
19+
#pragma clang diagnostic pop
20+
#else
21+
// this hack because `AnyPromise` is Swift, but we add
22+
// our own methods via the below category. This hack is
23+
// only required while building PromiseKit since, once
24+
// built, the generated -Swift header exists.
25+
26+
__attribute__((objc_subclassing_restricted)) __attribute__((objc_runtime_name("AnyPromise")))
27+
@interface AnyPromise : NSObject
28+
+ (instancetype __nonnull)promiseWithResolverBlock:(void (^ __nonnull)(__nonnull PMKResolver))resolveBlock;
29+
@end
30+
#endif
31+
32+
33+
34+
@interface AnyPromise (ObjC)
35+
36+
/**
37+
The provided block is executed when its receiver is resolved.
38+
39+
If you provide a block that takes a parameter, the value of the receiver will be passed as that parameter.
40+
41+
[NSURLSession GET:url].then(^(NSData *data){
42+
// do something with data
43+
});
44+
45+
@return A new promise that is resolved with the value returned from the provided block. For example:
46+
47+
[[NSURLSession shared] dataTaskWithURL:url].then(^(NSData *data){
48+
return data.length;
49+
}).then(^(NSNumber *number){
50+
//…
51+
});
52+
53+
@warning *Important* The block passed to `then` may take zero, one, two or three arguments, and return an object or return nothing. This flexibility is why the method signature for then is `id`, which means you will not get completion for the block parameter, and must type it yourself. It is safe to type any block syntax here, so to start with try just: `^{}`.
54+
55+
@warning *Important* If an `NSError` or `NSString` is thrown inside your block, or you return an `NSError` object the next `Promise` will be rejected. See `catch` for documentation on error handling.
56+
57+
@warning *Important* `then` is always executed on the main queue.
58+
59+
@see thenOn
60+
@see thenInBackground
61+
*/
62+
- (AnyPromise * __nonnull (^ __nonnull)(id __nonnull))then NS_REFINED_FOR_SWIFT;
63+
64+
/**
65+
The provided block is executed on the dispatch queue of your choice when the receiver is fulfilled.
66+
67+
@see then
68+
@see thenInBackground
69+
*/
70+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, id __nonnull))thenOn NS_REFINED_FOR_SWIFT;
71+
72+
/**
73+
The provided block is executed on the default queue when the receiver is fulfilled.
74+
75+
This method is provided as a convenience for `thenOn`.
76+
77+
@see then
78+
@see thenOn
79+
*/
80+
- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))thenInBackground NS_REFINED_FOR_SWIFT;
81+
82+
#ifndef __cplusplus
83+
/**
84+
The provided block is executed when the receiver is rejected.
85+
86+
Provide a block of form `^(NSError *){}` or simply `^{}`. The parameter has type `id` to give you the freedom to choose either.
87+
88+
The provided block always runs on the main queue.
89+
90+
@warning *Note* Cancellation errors are not caught.
91+
92+
@warning *Note* Since catch is a c++ keyword, this method is not availble in Objective-C++ files. Instead use catchWithPolicy.
93+
94+
@see catchWithPolicy
95+
*/
96+
- (AnyPromise * __nonnull(^ __nonnull)(id __nonnull))catch NS_REFINED_FOR_SWIFT;
97+
#endif
98+
99+
/**
100+
The provided block is executed when the receiver is resolved.
101+
102+
The provided block always runs on the main queue.
103+
104+
@see alwaysOn
105+
*/
106+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))ensure NS_REFINED_FOR_SWIFT;
107+
108+
/**
109+
The provided block is executed on the dispatch queue of your choice when the receiver is resolved.
110+
111+
@see always
112+
*/
113+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_queue_t __nonnull, dispatch_block_t __nonnull))ensureOn NS_REFINED_FOR_SWIFT;
114+
115+
116+
/// @see ensure
117+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))finally __attribute__((unavailable("Use ensure")));
118+
/// @see ensureOn
119+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull, dispatch_block_t __nonnull))finallyOn __attribute__((unavailable("Use ensureOn")));
120+
/// @see ensure
121+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull))always __attribute__((unavailable("Use ensure")));
122+
/// @see ensureOn
123+
- (AnyPromise * __nonnull(^ __nonnull)(dispatch_block_t __nonnull, dispatch_block_t __nonnull))alwaysOn __attribute__((unavailable("Use ensureOn")));
124+
125+
@end
126+
127+
128+
129+
#define PMKJSONDeserializationOptions ((NSJSONReadingOptions)(NSJSONReadingAllowFragments | NSJSONReadingMutableContainers))
130+
131+
132+
133+
/**
134+
Whenever resolving a promise you may resolve with a tuple, eg.
135+
returning from a `then` or `catch` handler or resolving a new promise.
136+
Consumers of your Promise are not compelled to consume any arguments and
137+
in fact will often only consume the first parameter. Thus ensure the
138+
order of parameters is: from most-important to least-important.
139+
Currently PromiseKit limits you to THREE parameters to the manifold.
140+
*/
141+
#define PMKManifold(...) __PMKManifold(__VA_ARGS__, 3, 2, 1)
142+
#define __PMKManifold(_1, _2, _3, N, ...) __PMKArrayWithCount(N, _1, _2, _3)
143+
extern id __nonnull __PMKArrayWithCount(NSUInteger, ...);
144+
145+
146+
147+
extern NSString * __nonnull const PMKErrorDomain;
148+
149+
#define PMKUnexpectedError 1l
150+
#define PMKInvalidUsageError 3l
151+
#define PMKAccessDeniedError 4l
152+
#define PMKOperationCancelled 5l
153+
#define PMKOperationFailed 8l
154+
#define PMKTaskError 9l
155+
#define PMKJoinError 10l
156+
157+
158+
159+
/**
160+
Really we shouldn’t assume JSON for (application|text)/(x-)javascript,
161+
really we should return a String of Javascript. However in practice
162+
for the apps we write it *will be* JSON. Thus if you actually want
163+
a Javascript String, use the promise variant of our category functions.
164+
*/
165+
#define PMKHTTPURLResponseIsJSON(rsp) [@[@"application/json", @"text/json", @"text/javascript", @"application/x-javascript", @"application/javascript"] containsObject:[rsp MIMEType]]
166+
#define PMKHTTPURLResponseIsImage(rsp) [@[@"image/tiff", @"image/jpeg", @"image/gif", @"image/png", @"image/ico", @"image/x-icon", @"image/bmp", @"image/x-bmp", @"image/x-xbitmap", @"image/x-win-bitmap"] containsObject:[rsp MIMEType]]
167+
#define PMKHTTPURLResponseIsText(rsp) [[rsp MIMEType] hasPrefix:@"text/"]
168+
169+
170+
171+
#if __cplusplus
172+
extern "C" {
173+
#endif
174+
175+
/**
176+
@return A new promise that resolves after the specified duration.
177+
@parameter duration The duration in seconds to wait before this promise is resolve.
178+
For example:
179+
PMKAfter(1).then(^{
180+
//…
181+
});
182+
*/
183+
extern AnyPromise * __nonnull PMKAfter(NSTimeInterval duration) NS_REFINED_FOR_SWIFT;
184+
185+
#if __cplusplus
186+
}
187+
#endif

0 commit comments

Comments
 (0)