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+Testing.h"
|
|
|
18 |
|
|
|
19 |
NS_ASSUME_NONNULL_BEGIN
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
Miscellaneous low-level private interfaces available to extend standard FBLPromise functionality.
|
|
|
23 |
*/
|
|
|
24 |
@interface FBLPromise<Value>()
|
|
|
25 |
|
|
|
26 |
typedef void (^FBLPromiseOnFulfillBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
|
|
|
27 |
typedef void (^FBLPromiseOnRejectBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
|
|
|
28 |
typedef id __nullable (^__nullable FBLPromiseChainedFulfillBlock)(Value __nullable value)
|
|
|
29 |
NS_SWIFT_UNAVAILABLE("");
|
|
|
30 |
typedef id __nullable (^__nullable FBLPromiseChainedRejectBlock)(NSError *error)
|
|
|
31 |
NS_SWIFT_UNAVAILABLE("");
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
Creates a pending promise.
|
|
|
35 |
*/
|
|
|
36 |
- (instancetype)initPending NS_SWIFT_UNAVAILABLE("");
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
Creates a resolved promise.
|
|
|
40 |
|
|
|
41 |
@param resolution An object to resolve the promise with: either a value or an error.
|
|
|
42 |
@return A new resolved promise.
|
|
|
43 |
*/
|
|
|
44 |
- (instancetype)initWithResolution:(nullable id)resolution NS_SWIFT_UNAVAILABLE("");
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
Invokes `fulfill` and `reject` blocks on `queue` when the receiver gets either fulfilled or
|
|
|
48 |
rejected respectively.
|
|
|
49 |
*/
|
|
|
50 |
- (void)observeOnQueue:(dispatch_queue_t)queue
|
|
|
51 |
fulfill:(FBLPromiseOnFulfillBlock)onFulfill
|
|
|
52 |
reject:(FBLPromiseOnRejectBlock)onReject NS_SWIFT_UNAVAILABLE("");
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
Returns a new promise which gets resolved with the return value of `chainedFulfill` or
|
|
|
56 |
`chainedReject` blocks respectively. The blocks are invoked when the receiver gets either
|
|
|
57 |
fulfilled or rejected. If `nil` is passed to either block arg, the returned promise is resolved
|
|
|
58 |
with the same resolution as the receiver.
|
|
|
59 |
*/
|
|
|
60 |
- (FBLPromise *)chainOnQueue:(dispatch_queue_t)queue
|
|
|
61 |
chainedFulfill:(FBLPromiseChainedFulfillBlock)chainedFulfill
|
|
|
62 |
chainedReject:(FBLPromiseChainedRejectBlock)chainedReject NS_SWIFT_UNAVAILABLE("");
|
|
|
63 |
|
|
|
64 |
@end
|
|
|
65 |
|
|
|
66 |
NS_ASSUME_NONNULL_END
|