commit | author | age
|
a6c014
|
1 |
/** |
L |
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>(ThenAdditions) |
|
22 |
|
|
23 |
typedef id __nullable (^FBLPromiseThenWorkBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE(""); |
|
24 |
|
|
25 |
/** |
|
26 |
Creates a pending promise which eventually gets resolved with resolution returned from `work` |
|
27 |
block: either value, error or another promise. The `work` block is executed asynchronously only |
|
28 |
when the receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with |
|
29 |
the same error. |
|
30 |
|
|
31 |
@param work A block to handle the value that receiver was fulfilled with. |
|
32 |
@return A new pending promise to be resolved with resolution returned from the `work` block. |
|
33 |
*/ |
|
34 |
- (FBLPromise *)then:(FBLPromiseThenWorkBlock)work NS_SWIFT_UNAVAILABLE(""); |
|
35 |
|
|
36 |
/** |
|
37 |
Creates a pending promise which eventually gets resolved with resolution returned from `work` |
|
38 |
block: either value, error or another promise. The `work` block is executed asynchronously when the |
|
39 |
receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with the same |
|
40 |
error. |
|
41 |
|
|
42 |
@param queue A queue to invoke the `work` block on. |
|
43 |
@param work A block to handle the value that receiver was fulfilled with. |
|
44 |
@return A new pending promise to be resolved with resolution returned from the `work` block. |
|
45 |
*/ |
|
46 |
- (FBLPromise *)onQueue:(dispatch_queue_t)queue |
|
47 |
then:(FBLPromiseThenWorkBlock)work NS_REFINED_FOR_SWIFT; |
|
48 |
|
|
49 |
@end |
|
50 |
|
|
51 |
/** |
|
52 |
Convenience dot-syntax wrappers for `FBLPromise` `then` operators. |
|
53 |
Usage: promise.then(^id(id value) { ... }) |
|
54 |
*/ |
|
55 |
@interface FBLPromise<Value>(DotSyntax_ThenAdditions) |
|
56 |
|
|
57 |
- (FBLPromise* (^)(FBLPromiseThenWorkBlock))then FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE(""); |
|
58 |
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseThenWorkBlock))thenOn FBL_PROMISES_DOT_SYNTAX |
|
59 |
NS_SWIFT_UNAVAILABLE(""); |
|
60 |
|
|
61 |
@end |
|
62 |
|
|
63 |
NS_ASSUME_NONNULL_END |