1 |
efrain |
1 |
/**
|
|
|
2 |
Copyright 2018 Google Inc. All rights reserved.
|
|
|
3 |
|
|
|
4 |
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
5 |
you may not use this file except in compliance with the License.
|
|
|
6 |
You may obtain a copy of the License at:
|
|
|
7 |
|
|
|
8 |
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
9 |
|
|
|
10 |
Unless required by applicable law or agreed to in writing, software
|
|
|
11 |
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
13 |
See the License for the specific language governing permissions and
|
|
|
14 |
limitations under the License.
|
|
|
15 |
*/
|
|
|
16 |
|
|
|
17 |
#import "FBLPromise.h"
|
|
|
18 |
|
|
|
19 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
20 |
|
|
|
21 |
@interface FBLPromise<Value>(AnyAdditions)
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
Waits until all of the given promises are either fulfilled or rejected.
|
|
|
25 |
If all promises are rejected, then the returned promise is rejected with same error
|
|
|
26 |
as the last one rejected.
|
|
|
27 |
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
|
|
|
28 |
values or `NSErrors`, matching the original order of fulfilled or rejected promises respectively.
|
|
|
29 |
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
|
|
30 |
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
|
|
31 |
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
|
|
32 |
|
|
|
33 |
@param promises Promises to wait for.
|
|
|
34 |
@return Promise of array containing the values or `NSError`s of input promises in the same order.
|
|
|
35 |
*/
|
|
|
36 |
+ (FBLPromise<NSArray *> *)any:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
Waits until all of the given promises are either fulfilled or rejected.
|
|
|
40 |
If all promises are rejected, then the returned promise is rejected with same error
|
|
|
41 |
as the last one rejected.
|
|
|
42 |
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
|
|
|
43 |
values or `NSError`s, matching the original order of fulfilled or rejected promises respectively.
|
|
|
44 |
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
|
|
45 |
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
|
|
46 |
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
|
|
47 |
|
|
|
48 |
@param queue A queue to dispatch on.
|
|
|
49 |
@param promises Promises to wait for.
|
|
|
50 |
@return Promise of array containing the values or `NSError`s of input promises in the same order.
|
|
|
51 |
*/
|
|
|
52 |
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
|
|
|
53 |
any:(NSArray *)promises NS_REFINED_FOR_SWIFT;
|
|
|
54 |
|
|
|
55 |
@end
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
Convenience dot-syntax wrappers for `FBLPromise` `any` operators.
|
|
|
59 |
Usage: FBLPromise.any(@[ ... ])
|
|
|
60 |
*/
|
|
|
61 |
@interface FBLPromise<Value>(DotSyntax_AnyAdditions)
|
|
|
62 |
|
|
|
63 |
+ (FBLPromise<NSArray *> * (^)(NSArray *))any FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
|
|
64 |
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))anyOn FBL_PROMISES_DOT_SYNTAX
|
|
|
65 |
NS_SWIFT_UNAVAILABLE("");
|
|
|
66 |
|
|
|
67 |
@end
|
|
|
68 |
|
|
|
69 |
NS_ASSUME_NONNULL_END
|