firebase log level
This commit is contained in:
202
Pods/PromisesObjC/LICENSE
generated
Normal file
202
Pods/PromisesObjC/LICENSE
generated
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
60
Pods/PromisesObjC/README.md
generated
Normal file
60
Pods/PromisesObjC/README.md
generated
Normal file
@ -0,0 +1,60 @@
|
||||
[](LICENSE)
|
||||
[](https://travis-ci.org/google/promises)
|
||||
[](https://gitter.im/google/promises)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
# Promises
|
||||
|
||||
Promises is a modern framework that provides a synchronization construct for
|
||||
Objective-C and Swift to facilitate writing asynchronous code.
|
||||
|
||||
* [Introduction](g3doc/index.md)
|
||||
* [The problem with async
|
||||
code](g3doc/index.md#the-problem-with-async-code)
|
||||
* [Promises to the rescue](g3doc/index.md#promises-to-the-rescue)
|
||||
* [What is a promise?](g3doc/index.md#what-is-a-promise)
|
||||
* [Framework](g3doc/index.md#framework)
|
||||
* [Features](g3doc/index.md#features)
|
||||
* [Benchmark](g3doc/index.md#benchmark)
|
||||
* [Getting started](g3doc/index.md#getting-started)
|
||||
* [Add dependency](g3doc/index.md#add-dependency)
|
||||
* [Import](g3doc/index.md#import)
|
||||
* [Adopt](g3doc/index.md#adopt)
|
||||
* [Basics](g3doc/index.md#basics)
|
||||
* [Creating promises](g3doc/index.md#creating-promises)
|
||||
* [Async](g3doc/index.md#async)
|
||||
* [Do](g3doc/index.md#do)
|
||||
* [Pending](g3doc/index.md#pending)
|
||||
* [Resolved](g3doc/index.md#create-a-resolved-promise)
|
||||
* [Observing fulfillment](g3doc/index.md#observing-fulfillment)
|
||||
* [Then](g3doc/index.md#then)
|
||||
* [Observing rejection](g3doc/index.md#observing-rejection)
|
||||
* [Catch](g3doc/index.md#catch)
|
||||
* [Extensions](g3doc/index.md#extensions)
|
||||
* [All](g3doc/index.md#all)
|
||||
* [Always](g3doc/index.md#always)
|
||||
* [Any](g3doc/index.md#any)
|
||||
* [AwaitPromise](g3doc/index.md#awaitpromise)
|
||||
* [Delay](g3doc/index.md#delay)
|
||||
* [Race](g3doc/index.md#race)
|
||||
* [Recover](g3doc/index.md#recover)
|
||||
* [Reduce](g3doc/index.md#reduce)
|
||||
* [Retry](g3doc/index.md#retry)
|
||||
* [Timeout](g3doc/index.md#timeout)
|
||||
* [Validate](g3doc/index.md#validate)
|
||||
* [Wrap](g3doc/index.md#wrap)
|
||||
* [Advanced topics](g3doc/index.md#advanced-topics)
|
||||
* [Default dispatch queue](g3doc/index.md#default-dispatch-queue)
|
||||
* [Ownership and retain
|
||||
cycles](g3doc/index.md#ownership-and-retain-cycles)
|
||||
* [Testing](g3doc/index.md#testing)
|
||||
* [Objective-C <-> Swift
|
||||
interoperability](g3doc/index.md#objective-c---swift-interoperability)
|
||||
* [Dot-syntax in Objective-C](g3doc/index.md#dot-syntax-in-objective-c)
|
||||
* [Anti-patterns](g3doc/index.md#anti-patterns)
|
||||
* [Broken chain](g3doc/index.md#broken-chain)
|
||||
* [Nested promises](g3doc/index.md#nested-promises)
|
||||
89
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+All.m
generated
Normal file
89
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+All.m
generated
Normal file
@ -0,0 +1,89 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+All.h"
|
||||
|
||||
#import "FBLPromise+Async.h"
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (AllAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> *)all:(NSArray *)promises {
|
||||
return [self onQueue:self.defaultDispatchQueue all:promises];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue all:(NSArray *)allPromises {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(allPromises);
|
||||
|
||||
if (allPromises.count == 0) {
|
||||
return [[self alloc] initWithResolution:@[]];
|
||||
}
|
||||
NSMutableArray *promises = [allPromises mutableCopy];
|
||||
return [self
|
||||
onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
for (NSUInteger i = 0; i < promises.count; ++i) {
|
||||
id promise = promises[i];
|
||||
if ([promise isKindOfClass:self]) {
|
||||
continue;
|
||||
} else if ([promise isKindOfClass:[NSError class]]) {
|
||||
reject(promise);
|
||||
return;
|
||||
} else {
|
||||
[promises replaceObjectAtIndex:i
|
||||
withObject:[[self alloc] initWithResolution:promise]];
|
||||
}
|
||||
}
|
||||
for (FBLPromise *promise in promises) {
|
||||
[promise observeOnQueue:queue
|
||||
fulfill:^(id __unused _) {
|
||||
// Wait until all are fulfilled.
|
||||
for (FBLPromise *promise in promises) {
|
||||
if (!promise.isFulfilled) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If called multiple times, only the first one affects the result.
|
||||
fulfill([promises valueForKey:NSStringFromSelector(@selector(value))]);
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
reject(error);
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_AllAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(NSArray *))all {
|
||||
return ^(NSArray<FBLPromise *> *promises) {
|
||||
return [self all:promises];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))allOn {
|
||||
return ^(dispatch_queue_t queue, NSArray<FBLPromise *> *promises) {
|
||||
return [self onQueue:queue all:promises];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeAllCategory(void) {}
|
||||
61
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Always.m
generated
Normal file
61
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Always.m
generated
Normal file
@ -0,0 +1,61 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Always.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (AlwaysAdditions)
|
||||
|
||||
- (FBLPromise *)always:(FBLPromiseAlwaysWorkBlock)work {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue always:work];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue always:(FBLPromiseAlwaysWorkBlock)work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self chainOnQueue:queue
|
||||
chainedFulfill:^id(id value) {
|
||||
work();
|
||||
return value;
|
||||
}
|
||||
chainedReject:^id(NSError *error) {
|
||||
work();
|
||||
return error;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_AlwaysAdditions)
|
||||
|
||||
- (FBLPromise * (^)(FBLPromiseAlwaysWorkBlock))always {
|
||||
return ^(FBLPromiseAlwaysWorkBlock work) {
|
||||
return [self always:work];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseAlwaysWorkBlock))alwaysOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseAlwaysWorkBlock work) {
|
||||
return [self onQueue:queue always:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeAlwaysCategory(void) {}
|
||||
115
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Any.m
generated
Normal file
115
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Any.m
generated
Normal file
@ -0,0 +1,115 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Any.h"
|
||||
|
||||
#import "FBLPromise+Async.h"
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
static NSArray *FBLPromiseCombineValuesAndErrors(NSArray<FBLPromise *> *promises) {
|
||||
NSMutableArray *combinedValuesAndErrors = [[NSMutableArray alloc] init];
|
||||
for (FBLPromise *promise in promises) {
|
||||
if (promise.isFulfilled) {
|
||||
[combinedValuesAndErrors addObject:promise.value ?: [NSNull null]];
|
||||
continue;
|
||||
}
|
||||
if (promise.isRejected) {
|
||||
[combinedValuesAndErrors addObject:promise.error];
|
||||
continue;
|
||||
}
|
||||
assert(!promise.isPending);
|
||||
};
|
||||
return combinedValuesAndErrors;
|
||||
}
|
||||
|
||||
@implementation FBLPromise (AnyAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> *)any:(NSArray *)promises {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue any:promises];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue any:(NSArray *)anyPromises {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(anyPromises);
|
||||
|
||||
if (anyPromises.count == 0) {
|
||||
return [[self alloc] initWithResolution:@[]];
|
||||
}
|
||||
NSMutableArray *promises = [anyPromises mutableCopy];
|
||||
return [self
|
||||
onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
for (NSUInteger i = 0; i < promises.count; ++i) {
|
||||
id promise = promises[i];
|
||||
if ([promise isKindOfClass:self]) {
|
||||
continue;
|
||||
} else {
|
||||
[promises replaceObjectAtIndex:i
|
||||
withObject:[[self alloc] initWithResolution:promise]];
|
||||
}
|
||||
}
|
||||
for (FBLPromise *promise in promises) {
|
||||
[promise observeOnQueue:queue
|
||||
fulfill:^(id __unused _) {
|
||||
// Wait until all are resolved.
|
||||
for (FBLPromise *promise in promises) {
|
||||
if (promise.isPending) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// If called multiple times, only the first one affects the result.
|
||||
fulfill(FBLPromiseCombineValuesAndErrors(promises));
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
BOOL atLeastOneIsFulfilled = NO;
|
||||
for (FBLPromise *promise in promises) {
|
||||
if (promise.isPending) {
|
||||
return;
|
||||
}
|
||||
if (promise.isFulfilled) {
|
||||
atLeastOneIsFulfilled = YES;
|
||||
}
|
||||
}
|
||||
if (atLeastOneIsFulfilled) {
|
||||
fulfill(FBLPromiseCombineValuesAndErrors(promises));
|
||||
} else {
|
||||
reject(error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_AnyAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(NSArray *))any {
|
||||
return ^(NSArray *promises) {
|
||||
return [self any:promises];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))anyOn {
|
||||
return ^(dispatch_queue_t queue, NSArray *promises) {
|
||||
return [self onQueue:queue any:promises];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeAnyCategory(void) {}
|
||||
73
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Async.m
generated
Normal file
73
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Async.m
generated
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Async.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (AsyncAdditions)
|
||||
|
||||
+ (instancetype)async:(FBLPromiseAsyncWorkBlock)work {
|
||||
return [self onQueue:self.defaultDispatchQueue async:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue async:(FBLPromiseAsyncWorkBlock)work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
FBLPromise *promise = [[self alloc] initPending];
|
||||
dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
|
||||
work(
|
||||
^(id __nullable value) {
|
||||
if ([value isKindOfClass:[FBLPromise class]]) {
|
||||
[(FBLPromise *)value observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
[promise reject:error];
|
||||
}];
|
||||
} else {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
},
|
||||
^(NSError *error) {
|
||||
[promise reject:error];
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_AsyncAdditions)
|
||||
|
||||
+ (FBLPromise* (^)(FBLPromiseAsyncWorkBlock))async {
|
||||
return ^(FBLPromiseAsyncWorkBlock work) {
|
||||
return [self async:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAsyncWorkBlock))asyncOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseAsyncWorkBlock work) {
|
||||
return [self onQueue:queue async:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeAsyncCategory(void) {}
|
||||
51
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Await.m
generated
Normal file
51
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Await.m
generated
Normal file
@ -0,0 +1,51 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Await.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
id __nullable FBLPromiseAwait(FBLPromise *promise, NSError **outError) {
|
||||
assert(promise);
|
||||
|
||||
static dispatch_once_t onceToken;
|
||||
static dispatch_queue_t queue;
|
||||
dispatch_once(&onceToken, ^{
|
||||
queue = dispatch_queue_create("com.google.FBLPromises.Await", DISPATCH_QUEUE_CONCURRENT);
|
||||
});
|
||||
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
||||
id __block resolution;
|
||||
NSError __block *blockError;
|
||||
[promise chainOnQueue:queue
|
||||
chainedFulfill:^id(id value) {
|
||||
resolution = value;
|
||||
dispatch_semaphore_signal(semaphore);
|
||||
return value;
|
||||
}
|
||||
chainedReject:^id(NSError *error) {
|
||||
blockError = error;
|
||||
dispatch_semaphore_signal(semaphore);
|
||||
return error;
|
||||
}];
|
||||
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||
if (outError) {
|
||||
*outError = blockError;
|
||||
}
|
||||
return resolution;
|
||||
}
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeAwaitCategory(void) {}
|
||||
58
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Catch.m
generated
Normal file
58
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Catch.m
generated
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Catch.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (CatchAdditions)
|
||||
|
||||
- (FBLPromise *)catch:(FBLPromiseCatchWorkBlock)reject {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue catch:reject];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue catch:(FBLPromiseCatchWorkBlock)reject {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(reject);
|
||||
|
||||
return [self chainOnQueue:queue
|
||||
chainedFulfill:nil
|
||||
chainedReject:^id(NSError *error) {
|
||||
reject(error);
|
||||
return error;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_CatchAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseCatchWorkBlock))catch {
|
||||
return ^(FBLPromiseCatchWorkBlock catch) {
|
||||
return [self catch:catch];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseCatchWorkBlock))catchOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseCatchWorkBlock catch) {
|
||||
return [self onQueue:queue catch:catch];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeCatchCategory(void) {}
|
||||
62
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Delay.m
generated
Normal file
62
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Delay.m
generated
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Delay.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (DelayAdditions)
|
||||
|
||||
- (FBLPromise *)delay:(NSTimeInterval)interval {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue delay:interval];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue delay:(NSTimeInterval)interval {
|
||||
NSParameterAssert(queue);
|
||||
|
||||
FBLPromise *promise = [[[self class] alloc] initPending];
|
||||
[self observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
dispatch_after(dispatch_time(0, (int64_t)(interval * NSEC_PER_SEC)), queue, ^{
|
||||
[promise fulfill:value];
|
||||
});
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
[promise reject:error];
|
||||
}];
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_DelayAdditions)
|
||||
|
||||
- (FBLPromise * (^)(NSTimeInterval))delay {
|
||||
return ^(NSTimeInterval interval) {
|
||||
return [self delay:interval];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise * (^)(dispatch_queue_t, NSTimeInterval))delayOn {
|
||||
return ^(dispatch_queue_t queue, NSTimeInterval interval) {
|
||||
return [self onQueue:queue delay:interval];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeDelayCategory(void) {}
|
||||
62
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Do.m
generated
Normal file
62
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Do.m
generated
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Do.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (DoAdditions)
|
||||
|
||||
+ (instancetype)do:(FBLPromiseDoWorkBlock)work {
|
||||
return [self onQueue:self.defaultDispatchQueue do:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue do:(FBLPromiseDoWorkBlock)work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
FBLPromise *promise = [[self alloc] initPending];
|
||||
dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
|
||||
id value = work();
|
||||
if ([value isKindOfClass:[FBLPromise class]]) {
|
||||
[(FBLPromise *)value observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
[promise reject:error];
|
||||
}];
|
||||
} else {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_DoAdditions)
|
||||
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, FBLPromiseDoWorkBlock))doOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseDoWorkBlock work) {
|
||||
return [self onQueue:queue do:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeDoCategory(void) {}
|
||||
68
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Race.m
generated
Normal file
68
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Race.m
generated
Normal file
@ -0,0 +1,68 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Race.h"
|
||||
|
||||
#import "FBLPromise+Async.h"
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (RaceAdditions)
|
||||
|
||||
+ (instancetype)race:(NSArray *)promises {
|
||||
return [self onQueue:self.defaultDispatchQueue race:promises];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue race:(NSArray *)racePromises {
|
||||
NSParameterAssert(queue);
|
||||
NSAssert(racePromises.count > 0, @"No promises to observe");
|
||||
|
||||
NSArray *promises = [racePromises copy];
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
for (id promise in promises) {
|
||||
if (![promise isKindOfClass:self]) {
|
||||
fulfill(promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Subscribe all, but only the first one to resolve will change
|
||||
// the resulting promise's state.
|
||||
for (FBLPromise *promise in promises) {
|
||||
[promise observeOnQueue:queue fulfill:fulfill reject:reject];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_RaceAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(NSArray *))race {
|
||||
return ^(NSArray *promises) {
|
||||
return [self race:promises];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, NSArray *))raceOn {
|
||||
return ^(dispatch_queue_t queue, NSArray *promises) {
|
||||
return [self onQueue:queue race:promises];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeRaceCategory(void) {}
|
||||
57
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Recover.m
generated
Normal file
57
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Recover.m
generated
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Recover.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (RecoverAdditions)
|
||||
|
||||
- (FBLPromise *)recover:(FBLPromiseRecoverWorkBlock)recovery {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue recover:recovery];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue recover:(FBLPromiseRecoverWorkBlock)recovery {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(recovery);
|
||||
|
||||
return [self chainOnQueue:queue
|
||||
chainedFulfill:nil
|
||||
chainedReject:^id(NSError *error) {
|
||||
return recovery(error);
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_RecoverAdditions)
|
||||
|
||||
- (FBLPromise * (^)(FBLPromiseRecoverWorkBlock))recover {
|
||||
return ^(FBLPromiseRecoverWorkBlock recovery) {
|
||||
return [self recover:recovery];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRecoverWorkBlock))recoverOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseRecoverWorkBlock recovery) {
|
||||
return [self onQueue:queue recover:recovery];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeRecoverCategory(void) {}
|
||||
64
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Reduce.m
generated
Normal file
64
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Reduce.m
generated
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Reduce.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (ReduceAdditions)
|
||||
|
||||
- (FBLPromise *)reduce:(NSArray *)items combine:(FBLPromiseReducerBlock)reducer {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue reduce:items combine:reducer];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
reduce:(NSArray *)items
|
||||
combine:(FBLPromiseReducerBlock)reducer {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(items);
|
||||
NSParameterAssert(reducer);
|
||||
|
||||
FBLPromise *promise = self;
|
||||
for (id item in items) {
|
||||
promise = [promise chainOnQueue:queue
|
||||
chainedFulfill:^id(id value) {
|
||||
return reducer(value, item);
|
||||
}
|
||||
chainedReject:nil];
|
||||
}
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_ReduceAdditions)
|
||||
|
||||
- (FBLPromise * (^)(NSArray *, FBLPromiseReducerBlock))reduce {
|
||||
return ^(NSArray *items, FBLPromiseReducerBlock reducer) {
|
||||
return [self reduce:items combine:reducer];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise * (^)(dispatch_queue_t, NSArray *, FBLPromiseReducerBlock))reduceOn {
|
||||
return ^(dispatch_queue_t queue, NSArray *items, FBLPromiseReducerBlock reducer) {
|
||||
return [self onQueue:queue reduce:items combine:reducer];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeReduceCategory(void) {}
|
||||
131
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Retry.m
generated
Normal file
131
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Retry.m
generated
Normal file
@ -0,0 +1,131 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Retry.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
NSInteger const FBLPromiseRetryDefaultAttemptsCount = 1;
|
||||
NSTimeInterval const FBLPromiseRetryDefaultDelayInterval = 1.0;
|
||||
|
||||
static void FBLPromiseRetryAttempt(FBLPromise *promise, dispatch_queue_t queue, NSInteger count,
|
||||
NSTimeInterval interval, FBLPromiseRetryPredicateBlock predicate,
|
||||
FBLPromiseRetryWorkBlock work) {
|
||||
__auto_type retrier = ^(id __nullable value) {
|
||||
if ([value isKindOfClass:[NSError class]]) {
|
||||
if (count <= 0 || (predicate && !predicate(count, value))) {
|
||||
[promise reject:value];
|
||||
} else {
|
||||
dispatch_after(dispatch_time(0, (int64_t)(interval * NSEC_PER_SEC)), queue, ^{
|
||||
FBLPromiseRetryAttempt(promise, queue, count - 1, interval, predicate, work);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
};
|
||||
id value = work();
|
||||
if ([value isKindOfClass:[FBLPromise class]]) {
|
||||
[(FBLPromise *)value observeOnQueue:queue fulfill:retrier reject:retrier];
|
||||
} else {
|
||||
retrier(value);
|
||||
}
|
||||
}
|
||||
|
||||
@implementation FBLPromise (RetryAdditions)
|
||||
|
||||
+ (instancetype)retry:(FBLPromiseRetryWorkBlock)work {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue retry:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue retry:(FBLPromiseRetryWorkBlock)work {
|
||||
return [self onQueue:queue attempts:FBLPromiseRetryDefaultAttemptsCount retry:work];
|
||||
}
|
||||
|
||||
+ (instancetype)attempts:(NSInteger)count retry:(FBLPromiseRetryWorkBlock)work {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue attempts:count retry:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
attempts:(NSInteger)count
|
||||
retry:(FBLPromiseRetryWorkBlock)work {
|
||||
return [self onQueue:queue
|
||||
attempts:count
|
||||
delay:FBLPromiseRetryDefaultDelayInterval
|
||||
condition:nil
|
||||
retry:work];
|
||||
}
|
||||
|
||||
+ (instancetype)attempts:(NSInteger)count
|
||||
delay:(NSTimeInterval)interval
|
||||
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
|
||||
retry:(FBLPromiseRetryWorkBlock)work {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue
|
||||
attempts:count
|
||||
delay:interval
|
||||
condition:predicate
|
||||
retry:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
attempts:(NSInteger)count
|
||||
delay:(NSTimeInterval)interval
|
||||
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
|
||||
retry:(FBLPromiseRetryWorkBlock)work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
FBLPromise *promise = [[self alloc] initPending];
|
||||
FBLPromiseRetryAttempt(promise, queue, count, interval, predicate, work);
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_RetryAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(FBLPromiseRetryWorkBlock))retry {
|
||||
return ^id(FBLPromiseRetryWorkBlock work) {
|
||||
return [self retry:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRetryWorkBlock))retryOn {
|
||||
return ^id(dispatch_queue_t queue, FBLPromiseRetryWorkBlock work) {
|
||||
return [self onQueue:queue retry:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(NSInteger, NSTimeInterval, FBLPromiseRetryPredicateBlock,
|
||||
FBLPromiseRetryWorkBlock))retryAgain {
|
||||
return ^id(NSInteger count, NSTimeInterval interval, FBLPromiseRetryPredicateBlock predicate,
|
||||
FBLPromiseRetryWorkBlock work) {
|
||||
return [self attempts:count delay:interval condition:predicate retry:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, NSInteger, NSTimeInterval, FBLPromiseRetryPredicateBlock,
|
||||
FBLPromiseRetryWorkBlock))retryAgainOn {
|
||||
return ^id(dispatch_queue_t queue, NSInteger count, NSTimeInterval interval,
|
||||
FBLPromiseRetryPredicateBlock predicate, FBLPromiseRetryWorkBlock work) {
|
||||
return [self onQueue:queue attempts:count delay:interval condition:predicate retry:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeRetryCategory(void) {}
|
||||
58
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Testing.m
generated
Normal file
58
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Testing.m
generated
Normal file
@ -0,0 +1,58 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Testing.h"
|
||||
|
||||
BOOL FBLWaitForPromisesWithTimeout(NSTimeInterval timeout) {
|
||||
BOOL isTimedOut = NO;
|
||||
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout];
|
||||
static NSTimeInterval const minimalTimeout = 0.01;
|
||||
static int64_t const minimalTimeToWait = (int64_t)(minimalTimeout * NSEC_PER_SEC);
|
||||
dispatch_time_t waitTime = dispatch_time(DISPATCH_TIME_NOW, minimalTimeToWait);
|
||||
dispatch_group_t dispatchGroup = FBLPromise.dispatchGroup;
|
||||
NSRunLoop *runLoop = NSRunLoop.currentRunLoop;
|
||||
while (dispatch_group_wait(dispatchGroup, waitTime)) {
|
||||
isTimedOut = timeoutDate.timeIntervalSinceNow < 0.0;
|
||||
if (isTimedOut) {
|
||||
break;
|
||||
}
|
||||
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:minimalTimeout]];
|
||||
}
|
||||
return !isTimedOut;
|
||||
}
|
||||
|
||||
@implementation FBLPromise (TestingAdditions)
|
||||
|
||||
// These properties are implemented in the FBLPromise class itself.
|
||||
@dynamic isPending;
|
||||
@dynamic isFulfilled;
|
||||
@dynamic isRejected;
|
||||
@dynamic value;
|
||||
@dynamic error;
|
||||
|
||||
+ (dispatch_group_t)dispatchGroup {
|
||||
static dispatch_group_t gDispatchGroup;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
gDispatchGroup = dispatch_group_create();
|
||||
});
|
||||
return gDispatchGroup;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeTestingCategory(void) {}
|
||||
53
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Then.m
generated
Normal file
53
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Then.m
generated
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Then.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (ThenAdditions)
|
||||
|
||||
- (FBLPromise *)then:(FBLPromiseThenWorkBlock)work {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue then:work];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue then:(FBLPromiseThenWorkBlock)work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self chainOnQueue:queue chainedFulfill:work chainedReject:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_ThenAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseThenWorkBlock))then {
|
||||
return ^(FBLPromiseThenWorkBlock work) {
|
||||
return [self then:work];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseThenWorkBlock))thenOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseThenWorkBlock work) {
|
||||
return [self onQueue:queue then:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeThenCategory(void) {}
|
||||
67
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Timeout.m
generated
Normal file
67
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Timeout.m
generated
Normal file
@ -0,0 +1,67 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Timeout.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (TimeoutAdditions)
|
||||
|
||||
- (FBLPromise *)timeout:(NSTimeInterval)interval {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue timeout:interval];
|
||||
}
|
||||
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue timeout:(NSTimeInterval)interval {
|
||||
NSParameterAssert(queue);
|
||||
|
||||
FBLPromise *promise = [[[self class] alloc] initPending];
|
||||
[self observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
[promise reject:error];
|
||||
}];
|
||||
FBLPromise* __weak weakPromise = promise;
|
||||
dispatch_after(dispatch_time(0, (int64_t)(interval * NSEC_PER_SEC)), queue, ^{
|
||||
NSError *timedOutError = [[NSError alloc] initWithDomain:FBLPromiseErrorDomain
|
||||
code:FBLPromiseErrorCodeTimedOut
|
||||
userInfo:nil];
|
||||
[weakPromise reject:timedOutError];
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_TimeoutAdditions)
|
||||
|
||||
- (FBLPromise* (^)(NSTimeInterval))timeout {
|
||||
return ^(NSTimeInterval interval) {
|
||||
return [self timeout:interval];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise* (^)(dispatch_queue_t, NSTimeInterval))timeoutOn {
|
||||
return ^(dispatch_queue_t queue, NSTimeInterval interval) {
|
||||
return [self onQueue:queue timeout:interval];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeTimeoutCategory(void) {}
|
||||
59
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Validate.m
generated
Normal file
59
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Validate.m
generated
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Validate.h"
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
@implementation FBLPromise (ValidateAdditions)
|
||||
|
||||
- (FBLPromise*)validate:(FBLPromiseValidateWorkBlock)predicate {
|
||||
return [self onQueue:FBLPromise.defaultDispatchQueue validate:predicate];
|
||||
}
|
||||
|
||||
- (FBLPromise*)onQueue:(dispatch_queue_t)queue validate:(FBLPromiseValidateWorkBlock)predicate {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(predicate);
|
||||
|
||||
FBLPromiseChainedFulfillBlock chainedFulfill = ^id(id value) {
|
||||
return predicate(value) ? value :
|
||||
[[NSError alloc] initWithDomain:FBLPromiseErrorDomain
|
||||
code:FBLPromiseErrorCodeValidationFailure
|
||||
userInfo:nil];
|
||||
};
|
||||
return [self chainOnQueue:queue chainedFulfill:chainedFulfill chainedReject:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_ValidateAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseValidateWorkBlock))validate {
|
||||
return ^(FBLPromiseValidateWorkBlock predicate) {
|
||||
return [self validate:predicate];
|
||||
};
|
||||
}
|
||||
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseValidateWorkBlock))validateOn {
|
||||
return ^(dispatch_queue_t queue, FBLPromiseValidateWorkBlock predicate) {
|
||||
return [self onQueue:queue validate:predicate];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeValidateCategory(void) {}
|
||||
423
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Wrap.m
generated
Normal file
423
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise+Wrap.m
generated
Normal file
@ -0,0 +1,423 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Wrap.h"
|
||||
|
||||
#import "FBLPromise+Async.h"
|
||||
|
||||
@implementation FBLPromise (WrapAdditions)
|
||||
|
||||
+ (instancetype)wrapCompletion:(void (^)(FBLPromiseCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapCompletion:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapCompletion:(void (^)(FBLPromiseCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock __unused _) {
|
||||
work(^{
|
||||
fulfill(nil);
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (instancetype)wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapObjectCompletion:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock __unused _) {
|
||||
work(^(id __nullable value) {
|
||||
fulfill(value);
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (instancetype)wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(nil);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (instancetype)wrapObjectOrErrorCompletion:(void (^)(FBLPromiseObjectOrErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapObjectOrErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapObjectOrErrorCompletion:(void (^)(FBLPromiseObjectOrErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(id __nullable value, NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(value);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (instancetype)wrapErrorOrObjectCompletion:(void (^)(FBLPromiseErrorOrObjectCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapErrorOrObjectCompletion:work];
|
||||
}
|
||||
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapErrorOrObjectCompletion:(void (^)(FBLPromiseErrorOrObjectCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(NSError *__nullable error, id __nullable value) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(value);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> *)wrap2ObjectsOrErrorCompletion:
|
||||
(void (^)(FBLPromise2ObjectsOrErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrap2ObjectsOrErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrap2ObjectsOrErrorCompletion:(void (^)(FBLPromise2ObjectsOrErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(id __nullable value1, id __nullable value2, NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(@[ value1 ?: [NSNull null], value2 ?: [NSNull null] ]);
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapBoolCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock __unused _) {
|
||||
work(^(BOOL value) {
|
||||
fulfill(@(value));
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapBoolOrErrorCompletion:
|
||||
(void (^)(FBLPromiseBoolOrErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapBoolOrErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapBoolOrErrorCompletion:(void (^)(FBLPromiseBoolOrErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(BOOL value, NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(@(value));
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapIntegerCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock __unused _) {
|
||||
work(^(NSInteger value) {
|
||||
fulfill(@(value));
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapIntegerOrErrorCompletion:
|
||||
(void (^)(FBLPromiseIntegerOrErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapIntegerOrErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapIntegerOrErrorCompletion:(void (^)(FBLPromiseIntegerOrErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(NSInteger value, NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(@(value));
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapDoubleCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:(dispatch_queue_t)queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock __unused _) {
|
||||
work(^(double value) {
|
||||
fulfill(@(value));
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)wrapDoubleOrErrorCompletion:
|
||||
(void (^)(FBLPromiseDoubleOrErrorCompletion))work {
|
||||
return [self onQueue:self.defaultDispatchQueue wrapDoubleOrErrorCompletion:work];
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> *)onQueue:(dispatch_queue_t)queue
|
||||
wrapDoubleOrErrorCompletion:(void (^)(FBLPromiseDoubleOrErrorCompletion))work {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(work);
|
||||
|
||||
return [self onQueue:queue
|
||||
async:^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) {
|
||||
work(^(double value, NSError *__nullable error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
fulfill(@(value));
|
||||
}
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntax_WrapAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(void (^)(FBLPromiseCompletion)))wrapCompletion {
|
||||
return ^(void (^work)(FBLPromiseCompletion)) {
|
||||
return [self wrapCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, void (^)(FBLPromiseCompletion)))wrapCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseCompletion)) {
|
||||
return [self onQueue:queue wrapCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletion {
|
||||
return ^(void (^work)(FBLPromiseObjectCompletion)) {
|
||||
return [self wrapObjectCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseObjectCompletion)) {
|
||||
return [self onQueue:queue wrapObjectCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletion {
|
||||
return ^(void (^work)(FBLPromiseErrorCompletion)) {
|
||||
return [self wrapErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseErrorCompletion)) {
|
||||
return [self onQueue:queue wrapErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletion {
|
||||
return ^(void (^work)(FBLPromiseObjectOrErrorCompletion)) {
|
||||
return [self wrapObjectOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseObjectOrErrorCompletion)) {
|
||||
return [self onQueue:queue wrapObjectOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletion {
|
||||
return ^(void (^work)(FBLPromiseErrorOrObjectCompletion)) {
|
||||
return [self wrapErrorOrObjectCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseErrorOrObjectCompletion)) {
|
||||
return [self onQueue:queue wrapErrorOrObjectCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(void (^)(FBLPromise2ObjectsOrErrorCompletion)))
|
||||
wrap2ObjectsOrErrorCompletion {
|
||||
return ^(void (^work)(FBLPromise2ObjectsOrErrorCompletion)) {
|
||||
return [self wrap2ObjectsOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, void (^)(FBLPromise2ObjectsOrErrorCompletion)))
|
||||
wrap2ObjectsOrErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromise2ObjectsOrErrorCompletion)) {
|
||||
return [self onQueue:queue wrap2ObjectsOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletion {
|
||||
return ^(void (^work)(FBLPromiseBoolCompletion)) {
|
||||
return [self wrapBoolCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseBoolCompletion)) {
|
||||
return [self onQueue:queue wrapBoolCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseBoolOrErrorCompletion)))
|
||||
wrapBoolOrErrorCompletion {
|
||||
return ^(void (^work)(FBLPromiseBoolOrErrorCompletion)) {
|
||||
return [self wrapBoolOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t, void (^)(FBLPromiseBoolOrErrorCompletion)))
|
||||
wrapBoolOrErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseBoolOrErrorCompletion)) {
|
||||
return [self onQueue:queue wrapBoolOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletion {
|
||||
return ^(void (^work)(FBLPromiseIntegerCompletion)) {
|
||||
return [self wrapIntegerCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseIntegerCompletion)) {
|
||||
return [self onQueue:queue wrapIntegerCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseIntegerOrErrorCompletion)))
|
||||
wrapIntegerOrErrorCompletion {
|
||||
return ^(void (^work)(FBLPromiseIntegerOrErrorCompletion)) {
|
||||
return [self wrapIntegerOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t, void (^)(FBLPromiseIntegerOrErrorCompletion)))
|
||||
wrapIntegerOrErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseIntegerOrErrorCompletion)) {
|
||||
return [self onQueue:queue wrapIntegerOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletion {
|
||||
return ^(void (^work)(FBLPromiseDoubleCompletion)) {
|
||||
return [self wrapDoubleCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseDoubleCompletion)) {
|
||||
return [self onQueue:queue wrapDoubleCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(void (^)(FBLPromiseDoubleOrErrorCompletion)))
|
||||
wrapDoubleOrErrorCompletion {
|
||||
return ^(void (^work)(FBLPromiseDoubleOrErrorCompletion)) {
|
||||
return [self wrapDoubleOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise<NSNumber *> * (^)(dispatch_queue_t, void (^)(FBLPromiseDoubleOrErrorCompletion)))
|
||||
wrapDoubleOrErrorCompletionOn {
|
||||
return ^(dispatch_queue_t queue, void (^work)(FBLPromiseDoubleOrErrorCompletion)) {
|
||||
return [self onQueue:queue wrapDoubleOrErrorCompletion:work];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/** Stub used to force the linker to include the categories in this file. */
|
||||
void FBLIncludeWrapCategory(void) {}
|
||||
346
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise.m
generated
Normal file
346
Pods/PromisesObjC/Sources/FBLPromises/FBLPromise.m
generated
Normal file
@ -0,0 +1,346 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromisePrivate.h"
|
||||
|
||||
/** All states a promise can be in. */
|
||||
typedef NS_ENUM(NSInteger, FBLPromiseState) {
|
||||
FBLPromiseStatePending = 0,
|
||||
FBLPromiseStateFulfilled,
|
||||
FBLPromiseStateRejected,
|
||||
};
|
||||
|
||||
typedef void (^FBLPromiseObserver)(FBLPromiseState state, id __nullable resolution);
|
||||
|
||||
static dispatch_queue_t gFBLPromiseDefaultDispatchQueue;
|
||||
|
||||
@implementation FBLPromise {
|
||||
/** Current state of the promise. */
|
||||
FBLPromiseState _state;
|
||||
/**
|
||||
Set of arbitrary objects to keep strongly while the promise is pending.
|
||||
Becomes nil after the promise has been resolved.
|
||||
*/
|
||||
NSMutableSet *__nullable _pendingObjects;
|
||||
/**
|
||||
Value to fulfill the promise with.
|
||||
Can be nil if the promise is still pending, was resolved with nil or after it has been rejected.
|
||||
*/
|
||||
id __nullable _value;
|
||||
/**
|
||||
Error to reject the promise with.
|
||||
Can be nil if the promise is still pending or after it has been fulfilled.
|
||||
*/
|
||||
NSError *__nullable _error;
|
||||
/** List of observers to notify when the promise gets resolved. */
|
||||
NSMutableArray<FBLPromiseObserver> *_observers;
|
||||
}
|
||||
|
||||
+ (void)initialize {
|
||||
if (self == [FBLPromise class]) {
|
||||
gFBLPromiseDefaultDispatchQueue = dispatch_get_main_queue();
|
||||
}
|
||||
}
|
||||
|
||||
+ (dispatch_queue_t)defaultDispatchQueue {
|
||||
@synchronized(self) {
|
||||
return gFBLPromiseDefaultDispatchQueue;
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)setDefaultDispatchQueue:(dispatch_queue_t)queue {
|
||||
NSParameterAssert(queue);
|
||||
|
||||
@synchronized(self) {
|
||||
gFBLPromiseDefaultDispatchQueue = queue;
|
||||
}
|
||||
}
|
||||
|
||||
+ (instancetype)pendingPromise {
|
||||
return [[self alloc] initPending];
|
||||
}
|
||||
|
||||
+ (instancetype)resolvedWith:(nullable id)resolution {
|
||||
return [[self alloc] initWithResolution:resolution];
|
||||
}
|
||||
|
||||
- (void)fulfill:(nullable id)value {
|
||||
if ([value isKindOfClass:[NSError class]]) {
|
||||
[self reject:(NSError *)value];
|
||||
} else {
|
||||
@synchronized(self) {
|
||||
if (_state == FBLPromiseStatePending) {
|
||||
_state = FBLPromiseStateFulfilled;
|
||||
_value = value;
|
||||
_pendingObjects = nil;
|
||||
for (FBLPromiseObserver observer in _observers) {
|
||||
observer(_state, _value);
|
||||
}
|
||||
_observers = nil;
|
||||
dispatch_group_leave(FBLPromise.dispatchGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)reject:(NSError *)error {
|
||||
NSAssert([error isKindOfClass:[NSError class]], @"Invalid error type.");
|
||||
|
||||
if (![error isKindOfClass:[NSError class]]) {
|
||||
// Give up on invalid error type in Release mode.
|
||||
@throw error; // NOLINT
|
||||
}
|
||||
@synchronized(self) {
|
||||
if (_state == FBLPromiseStatePending) {
|
||||
_state = FBLPromiseStateRejected;
|
||||
_error = error;
|
||||
_pendingObjects = nil;
|
||||
for (FBLPromiseObserver observer in _observers) {
|
||||
observer(_state, _error);
|
||||
}
|
||||
_observers = nil;
|
||||
dispatch_group_leave(FBLPromise.dispatchGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - NSObject
|
||||
|
||||
- (NSString *)description {
|
||||
if (self.isFulfilled) {
|
||||
return [NSString stringWithFormat:@"<%@ %p> Fulfilled: %@", NSStringFromClass([self class]),
|
||||
self, self.value];
|
||||
}
|
||||
if (self.isRejected) {
|
||||
return [NSString stringWithFormat:@"<%@ %p> Rejected: %@", NSStringFromClass([self class]),
|
||||
self, self.error];
|
||||
}
|
||||
return [NSString stringWithFormat:@"<%@ %p> Pending", NSStringFromClass([self class]), self];
|
||||
}
|
||||
|
||||
#pragma mark - Private
|
||||
|
||||
- (instancetype)initPending {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
dispatch_group_enter(FBLPromise.dispatchGroup);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithResolution:(nullable id)resolution {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
if ([resolution isKindOfClass:[NSError class]]) {
|
||||
_state = FBLPromiseStateRejected;
|
||||
_error = (NSError *)resolution;
|
||||
} else {
|
||||
_state = FBLPromiseStateFulfilled;
|
||||
_value = resolution;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
if (_state == FBLPromiseStatePending) {
|
||||
dispatch_group_leave(FBLPromise.dispatchGroup);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isPending {
|
||||
@synchronized(self) {
|
||||
return _state == FBLPromiseStatePending;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isFulfilled {
|
||||
@synchronized(self) {
|
||||
return _state == FBLPromiseStateFulfilled;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isRejected {
|
||||
@synchronized(self) {
|
||||
return _state == FBLPromiseStateRejected;
|
||||
}
|
||||
}
|
||||
|
||||
- (nullable id)value {
|
||||
@synchronized(self) {
|
||||
return _value;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSError *__nullable)error {
|
||||
@synchronized(self) {
|
||||
return _error;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addPendingObject:(id)object {
|
||||
NSParameterAssert(object);
|
||||
|
||||
@synchronized(self) {
|
||||
if (_state == FBLPromiseStatePending) {
|
||||
if (!_pendingObjects) {
|
||||
_pendingObjects = [[NSMutableSet alloc] init];
|
||||
}
|
||||
[_pendingObjects addObject:object];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)observeOnQueue:(dispatch_queue_t)queue
|
||||
fulfill:(FBLPromiseOnFulfillBlock)onFulfill
|
||||
reject:(FBLPromiseOnRejectBlock)onReject {
|
||||
NSParameterAssert(queue);
|
||||
NSParameterAssert(onFulfill);
|
||||
NSParameterAssert(onReject);
|
||||
|
||||
@synchronized(self) {
|
||||
switch (_state) {
|
||||
case FBLPromiseStatePending: {
|
||||
if (!_observers) {
|
||||
_observers = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[_observers addObject:^(FBLPromiseState state, id __nullable resolution) {
|
||||
dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
|
||||
switch (state) {
|
||||
case FBLPromiseStatePending:
|
||||
break;
|
||||
case FBLPromiseStateFulfilled:
|
||||
onFulfill(resolution);
|
||||
break;
|
||||
case FBLPromiseStateRejected:
|
||||
onReject(resolution);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}];
|
||||
break;
|
||||
}
|
||||
case FBLPromiseStateFulfilled: {
|
||||
dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
|
||||
onFulfill(self->_value);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case FBLPromiseStateRejected: {
|
||||
dispatch_group_async(FBLPromise.dispatchGroup, queue, ^{
|
||||
onReject(self->_error);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (FBLPromise *)chainOnQueue:(dispatch_queue_t)queue
|
||||
chainedFulfill:(FBLPromiseChainedFulfillBlock)chainedFulfill
|
||||
chainedReject:(FBLPromiseChainedRejectBlock)chainedReject {
|
||||
NSParameterAssert(queue);
|
||||
|
||||
FBLPromise *promise = [[[self class] alloc] initPending];
|
||||
__auto_type resolver = ^(id __nullable value) {
|
||||
if ([value isKindOfClass:[FBLPromise class]]) {
|
||||
[(FBLPromise *)value observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
[promise reject:error];
|
||||
}];
|
||||
} else {
|
||||
[promise fulfill:value];
|
||||
}
|
||||
};
|
||||
[self observeOnQueue:queue
|
||||
fulfill:^(id __nullable value) {
|
||||
value = chainedFulfill ? chainedFulfill(value) : value;
|
||||
resolver(value);
|
||||
}
|
||||
reject:^(NSError *error) {
|
||||
id value = chainedReject ? chainedReject(error) : error;
|
||||
resolver(value);
|
||||
}];
|
||||
return promise;
|
||||
}
|
||||
|
||||
#pragma mark - Category linking workaround
|
||||
|
||||
extern void FBLIncludeAllCategory(void);
|
||||
extern void FBLIncludeAlwaysCategory(void);
|
||||
extern void FBLIncludeAnyCategory(void);
|
||||
extern void FBLIncludeAsyncCategory(void);
|
||||
extern void FBLIncludeAwaitCategory(void);
|
||||
extern void FBLIncludeCatchCategory(void);
|
||||
extern void FBLIncludeDelayCategory(void);
|
||||
extern void FBLIncludeDoCategory(void);
|
||||
extern void FBLIncludeRaceCategory(void);
|
||||
extern void FBLIncludeRecoverCategory(void);
|
||||
extern void FBLIncludeReduceCategory(void);
|
||||
extern void FBLIncludeRetryCategory(void);
|
||||
extern void FBLIncludeTestingCategory(void);
|
||||
extern void FBLIncludeThenCategory(void);
|
||||
extern void FBLIncludeTimeoutCategory(void);
|
||||
extern void FBLIncludeValidateCategory(void);
|
||||
extern void FBLIncludeWrapCategory(void);
|
||||
|
||||
/**
|
||||
Does nothing when called, and not meant to be called.
|
||||
|
||||
This method forces the linker to include all FBLPromise categories even if
|
||||
users do not include the '-ObjC' linker flag in their projects.
|
||||
*/
|
||||
+ (void)noop {
|
||||
FBLIncludeAllCategory();
|
||||
FBLIncludeAllCategory();
|
||||
FBLIncludeAlwaysCategory();
|
||||
FBLIncludeAnyCategory();
|
||||
FBLIncludeAsyncCategory();
|
||||
FBLIncludeAwaitCategory();
|
||||
FBLIncludeCatchCategory();
|
||||
FBLIncludeDelayCategory();
|
||||
FBLIncludeDoCategory();
|
||||
FBLIncludeRaceCategory();
|
||||
FBLIncludeRecoverCategory();
|
||||
FBLIncludeReduceCategory();
|
||||
FBLIncludeRetryCategory();
|
||||
FBLIncludeTestingCategory();
|
||||
FBLIncludeThenCategory();
|
||||
FBLIncludeTimeoutCategory();
|
||||
FBLIncludeValidateCategory();
|
||||
FBLIncludeWrapCategory();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation FBLPromise (DotSyntaxAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(void))pending {
|
||||
return ^(void) {
|
||||
return [self pendingPromise];
|
||||
};
|
||||
}
|
||||
|
||||
+ (FBLPromise * (^)(id __nullable))resolved {
|
||||
return ^(id resolution) {
|
||||
return [self resolvedWith:resolution];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
19
Pods/PromisesObjC/Sources/FBLPromises/FBLPromiseError.m
generated
Normal file
19
Pods/PromisesObjC/Sources/FBLPromises/FBLPromiseError.m
generated
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromiseError.h"
|
||||
|
||||
NSErrorDomain const FBLPromiseErrorDomain = @"com.google.FBLPromises.Error";
|
||||
14
Pods/PromisesObjC/Sources/FBLPromises/Resources/PrivacyInfo.xcprivacy
generated
Normal file
14
Pods/PromisesObjC/Sources/FBLPromises/Resources/PrivacyInfo.xcprivacy
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSPrivacyAccessedAPITypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyCollectedDataTypes</key>
|
||||
<array/>
|
||||
<key>NSPrivacyTracking</key>
|
||||
<false/>
|
||||
<key>NSPrivacyTrackingDomains</key>
|
||||
<array/>
|
||||
</dict>
|
||||
</plist>
|
||||
63
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+All.h
generated
Normal file
63
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+All.h
generated
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(AllAdditions)
|
||||
|
||||
/**
|
||||
Wait until all of the given promises are fulfilled.
|
||||
If one of the given promises is rejected, then the returned promise is rejected with same error.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
||||
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
||||
|
||||
@param promises Promises to wait for.
|
||||
@return Promise of an array containing the values of input promises in the same order.
|
||||
*/
|
||||
+ (FBLPromise<NSArray *> *)all:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Wait until all of the given promises are fulfilled.
|
||||
If one of the given promises is rejected, then the returned promise is rejected with same error.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected FBLPromise correspondingly.
|
||||
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param promises Promises to wait for.
|
||||
@return Promise of an array containing the values of input promises in the same order.
|
||||
*/
|
||||
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
|
||||
all:(NSArray *)promises NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `all` operators.
|
||||
Usage: FBLPromise.all(@[ ... ])
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_AllAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(NSArray *))all FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))allOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
54
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Always.h
generated
Normal file
54
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Always.h
generated
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(AlwaysAdditions)
|
||||
|
||||
typedef void (^FBLPromiseAlwaysWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block that always executes, no matter if the receiver is rejected or fulfilled.
|
||||
@return A new pending promise to be resolved with same resolution as the receiver.
|
||||
*/
|
||||
- (FBLPromise *)always:(FBLPromiseAlwaysWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to dispatch on.
|
||||
@param work A block that always executes, no matter if the receiver is rejected or fulfilled.
|
||||
@return A new pending promise to be resolved with same resolution as the receiver.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
always:(FBLPromiseAlwaysWorkBlock)work NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `always` operators.
|
||||
Usage: promise.always(^{...})
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_AlwaysAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseAlwaysWorkBlock))always FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAlwaysWorkBlock))alwaysOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
69
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Any.h
generated
Normal file
69
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Any.h
generated
Normal file
@ -0,0 +1,69 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(AnyAdditions)
|
||||
|
||||
/**
|
||||
Waits until all of the given promises are either fulfilled or rejected.
|
||||
If all promises are rejected, then the returned promise is rejected with same error
|
||||
as the last one rejected.
|
||||
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
|
||||
values or `NSErrors`, matching the original order of fulfilled or rejected promises respectively.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
||||
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
||||
|
||||
@param promises Promises to wait for.
|
||||
@return Promise of array containing the values or `NSError`s of input promises in the same order.
|
||||
*/
|
||||
+ (FBLPromise<NSArray *> *)any:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Waits until all of the given promises are either fulfilled or rejected.
|
||||
If all promises are rejected, then the returned promise is rejected with same error
|
||||
as the last one rejected.
|
||||
If at least one of the promises is fulfilled, the resulting promise is fulfilled with an array of
|
||||
values or `NSError`s, matching the original order of fulfilled or rejected promises respectively.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
||||
Promises resolved with `nil` become `NSNull` instances in the resulting array.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param promises Promises to wait for.
|
||||
@return Promise of array containing the values or `NSError`s of input promises in the same order.
|
||||
*/
|
||||
+ (FBLPromise<NSArray *> *)onQueue:(dispatch_queue_t)queue
|
||||
any:(NSArray *)promises NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `any` operators.
|
||||
Usage: FBLPromise.any(@[ ... ])
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_AnyAdditions)
|
||||
|
||||
+ (FBLPromise<NSArray *> * (^)(NSArray *))any FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSArray *> * (^)(dispatch_queue_t, NSArray *))anyOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Async.h
generated
Normal file
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Async.h
generated
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(AsyncAdditions)
|
||||
|
||||
typedef void (^FBLPromiseFulfillBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseRejectBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseAsyncWorkBlock)(FBLPromiseFulfillBlock fulfill,
|
||||
FBLPromiseRejectBlock reject) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise and executes `work` block asynchronously.
|
||||
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
+ (instancetype)async:(FBLPromiseAsyncWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise and executes `work` block asynchronously on the given queue.
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
async:(FBLPromiseAsyncWorkBlock)work NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `async` operators.
|
||||
Usage: FBLPromise.async(^(FBLPromiseFulfillBlock fulfill, FBLPromiseRejectBlock reject) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_AsyncAdditions)
|
||||
|
||||
+ (FBLPromise* (^)(FBLPromiseAsyncWorkBlock))async FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAsyncWorkBlock))asyncOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
32
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Await.h
generated
Normal file
32
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Await.h
generated
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Waits for promise resolution. The current thread blocks until the promise is resolved.
|
||||
|
||||
@param promise Promise to wait for.
|
||||
@param error Error the promise was rejected with, or `nil` if the promise was fulfilled.
|
||||
@return Value the promise was fulfilled with. If the promise was rejected, the return value
|
||||
is always `nil`, but the error out arg is not.
|
||||
*/
|
||||
FOUNDATION_EXTERN id __nullable FBLPromiseAwait(FBLPromise *promise,
|
||||
NSError **error) NS_REFINED_FOR_SWIFT;
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
59
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Catch.h
generated
Normal file
59
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Catch.h
generated
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(CatchAdditions)
|
||||
|
||||
typedef void (^FBLPromiseCatchWorkBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise which eventually gets resolved with same resolution as the receiver.
|
||||
If receiver is rejected, then `reject` block is executed asynchronously.
|
||||
|
||||
@param reject A block to handle the error that receiver was rejected with.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
- (FBLPromise *)catch:(FBLPromiseCatchWorkBlock)reject NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise which eventually gets resolved with same resolution as the receiver.
|
||||
If receiver is rejected, then `reject` block is executed asynchronously on the given queue.
|
||||
|
||||
@param queue A queue to invoke the `reject` block on.
|
||||
@param reject A block to handle the error that receiver was rejected with.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
catch:(FBLPromiseCatchWorkBlock)reject NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `catch` operators.
|
||||
Usage: promise.catch(^(NSError *error) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_CatchAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseCatchWorkBlock))catch FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseCatchWorkBlock))catchOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
59
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Delay.h
generated
Normal file
59
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Delay.h
generated
Normal file
@ -0,0 +1,59 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(DelayAdditions)
|
||||
|
||||
/**
|
||||
Creates a new pending promise that fulfills with the same value as `self` after the `delay`, or
|
||||
rejects with the same error immediately.
|
||||
|
||||
@param interval Time to wait in seconds.
|
||||
@return A new pending promise that fulfills at least `delay` seconds later than `self`, or rejects
|
||||
with the same error immediately.
|
||||
*/
|
||||
- (FBLPromise *)delay:(NSTimeInterval)interval NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a new pending promise that fulfills with the same value as `self` after the `delay`, or
|
||||
rejects with the same error immediately.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param interval Time to wait in seconds.
|
||||
@return A new pending promise that fulfills at least `delay` seconds later than `self`, or rejects
|
||||
with the same error immediately.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
delay:(NSTimeInterval)interval NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `delay` operators.
|
||||
Usage: promise.delay(...)
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_DelayAdditions)
|
||||
|
||||
- (FBLPromise * (^)(NSTimeInterval))delay FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise * (^)(dispatch_queue_t, NSTimeInterval))delayOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
55
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Do.h
generated
Normal file
55
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Do.h
generated
Normal file
@ -0,0 +1,55 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(DoAdditions)
|
||||
|
||||
typedef id __nullable (^FBLPromiseDoWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise and executes `work` block asynchronously.
|
||||
|
||||
@param work A block that returns a value or an error used to resolve the promise.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
+ (instancetype)do:(FBLPromiseDoWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise and executes `work` block asynchronously on the given queue.
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block that returns a value or an error used to resolve the promise.
|
||||
@return A new pending promise.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue do:(FBLPromiseDoWorkBlock)work NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `do` operators.
|
||||
Usage: FBLPromise.doOn(queue, ^(NSError *error) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_DoAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, FBLPromiseDoWorkBlock))doOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
62
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Race.h
generated
Normal file
62
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Race.h
generated
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(RaceAdditions)
|
||||
|
||||
/**
|
||||
Wait until any of the given promises are fulfilled.
|
||||
If one of the promises is rejected, then the returned promise is rejected with same error.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
||||
|
||||
@param promises Promises to wait for.
|
||||
@return A new pending promise to be resolved with the same resolution as the first promise, among
|
||||
the given ones, which was resolved.
|
||||
*/
|
||||
+ (instancetype)race:(NSArray *)promises NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Wait until any of the given promises are fulfilled.
|
||||
If one of the promises is rejected, then the returned promise is rejected with same error.
|
||||
If any other arbitrary value or `NSError` appears in the array instead of `FBLPromise`,
|
||||
it's implicitly considered a pre-fulfilled or pre-rejected `FBLPromise` correspondingly.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param promises Promises to wait for.
|
||||
@return A new pending promise to be resolved with the same resolution as the first promise, among
|
||||
the given ones, which was resolved.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue race:(NSArray *)promises NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `race` operators.
|
||||
Usage: FBLPromise.race(@[ ... ])
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_RaceAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(NSArray *))race FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, NSArray *))raceOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Recover.h
generated
Normal file
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Recover.h
generated
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(RecoverAdditions)
|
||||
|
||||
typedef id __nullable (^FBLPromiseRecoverWorkBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Provides a new promise to recover in case the receiver gets rejected.
|
||||
|
||||
@param recovery A block to handle the error that the receiver was rejected with.
|
||||
@return A new pending promise to use instead of the rejected one that gets resolved with resolution
|
||||
returned from `recovery` block.
|
||||
*/
|
||||
- (FBLPromise *)recover:(FBLPromiseRecoverWorkBlock)recovery NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Provides a new promise to recover in case the receiver gets rejected.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param recovery A block to handle the error that the receiver was rejected with.
|
||||
@return A new pending promise to use instead of the rejected one that gets resolved with resolution
|
||||
returned from `recovery` block.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
recover:(FBLPromiseRecoverWorkBlock)recovery NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `recover` operators.
|
||||
Usage: promise.recover(^id(NSError *error) {...})
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_RecoverAdditions)
|
||||
|
||||
- (FBLPromise * (^)(FBLPromiseRecoverWorkBlock))recover FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRecoverWorkBlock))recoverOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
71
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Reduce.h
generated
Normal file
71
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Reduce.h
generated
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(ReduceAdditions)
|
||||
|
||||
typedef id __nullable (^FBLPromiseReducerBlock)(Value __nullable partial, id next)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Sequentially reduces a collection of values to a single promise using a given combining block
|
||||
and the value `self` resolves with as initial value.
|
||||
|
||||
@param items An array of values to process in order.
|
||||
@param reducer A block to combine an accumulating value and an element of the sequence into
|
||||
the new accumulating value or a promise resolved with it, to be used in the next
|
||||
call of the `reducer` or returned to the caller.
|
||||
@return A new pending promise returned from the last `reducer` invocation.
|
||||
Or `self` if `items` is empty.
|
||||
*/
|
||||
- (FBLPromise *)reduce:(NSArray *)items
|
||||
combine:(FBLPromiseReducerBlock)reducer NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Sequentially reduces a collection of values to a single promise using a given combining block
|
||||
and the value `self` resolves with as initial value.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param items An array of values to process in order.
|
||||
@param reducer A block to combine an accumulating value and an element of the sequence into
|
||||
the new accumulating value or a promise resolved with it, to be used in the next
|
||||
call of the `reducer` or returned to the caller.
|
||||
@return A new pending promise returned from the last `reducer` invocation.
|
||||
Or `self` if `items` is empty.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
reduce:(NSArray *)items
|
||||
combine:(FBLPromiseReducerBlock)reducer NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `reduce` operators.
|
||||
Usage: promise.reduce(values, ^id(id partial, id next) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_ReduceAdditions)
|
||||
|
||||
- (FBLPromise * (^)(NSArray *, FBLPromiseReducerBlock))reduce FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise * (^)(dispatch_queue_t, NSArray *, FBLPromiseReducerBlock))reduceOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
165
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Retry.h
generated
Normal file
165
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Retry.h
generated
Normal file
@ -0,0 +1,165 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** The default number of retry attempts is 1. */
|
||||
FOUNDATION_EXTERN NSInteger const FBLPromiseRetryDefaultAttemptsCount NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/** The default delay interval before making a retry attempt is 1.0 second. */
|
||||
FOUNDATION_EXTERN NSTimeInterval const FBLPromiseRetryDefaultDelayInterval NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@interface FBLPromise<Value>(RetryAdditions)
|
||||
|
||||
typedef id __nullable (^FBLPromiseRetryWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef BOOL (^FBLPromiseRetryPredicateBlock)(NSInteger, NSError *) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously, or rejects with the same error after all retry attempts have
|
||||
been exhausted. Defaults to `FBLPromiseRetryDefaultAttemptsCount` attempt(s) on rejection where the
|
||||
`work` block is retried after a delay of `FBLPromiseRetryDefaultDelayInterval` second(s).
|
||||
|
||||
@param work A block that executes asynchronously on the default queue and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted.
|
||||
*/
|
||||
+ (instancetype)retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
|
||||
retry attempts have been exhausted. Defaults to `FBLPromiseRetryDefaultAttemptsCount` attempt(s) on
|
||||
rejection where the `work` block is retried on the given `queue` after a delay of
|
||||
`FBLPromiseRetryDefaultDelayInterval` second(s).
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block that executes asynchronously on the given `queue` and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously, or rejects with the same error after all retry attempts have
|
||||
been exhausted.
|
||||
|
||||
@param count Max number of retry attempts. The `work` block will be executed once if the specified
|
||||
count is less than or equal to zero.
|
||||
@param work A block that executes asynchronously on the default queue and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted.
|
||||
*/
|
||||
+ (instancetype)attempts:(NSInteger)count
|
||||
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
|
||||
retry attempts have been exhausted.
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param count Max number of retry attempts. The `work` block will be executed once if the specified
|
||||
count is less than or equal to zero.
|
||||
@param work A block that executes asynchronously on the given `queue` and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
attempts:(NSInteger)count
|
||||
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously, or rejects with the same error after all retry attempts have
|
||||
been exhausted. On rejection, the `work` block is retried after the given delay `interval` and will
|
||||
continue to retry until the number of specified attempts have been exhausted or will bail early if
|
||||
the given condition is not met.
|
||||
|
||||
@param count Max number of retry attempts. The `work` block will be executed once if the specified
|
||||
count is less than or equal to zero.
|
||||
@param interval Time to wait before the next retry attempt.
|
||||
@param predicate Condition to check before the next retry attempt. The predicate block provides the
|
||||
the number of remaining retry attempts and the error that the promise was rejected
|
||||
with.
|
||||
@param work A block that executes asynchronously on the default queue and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted or if
|
||||
the given condition is not met.
|
||||
*/
|
||||
+ (instancetype)attempts:(NSInteger)count
|
||||
delay:(NSTimeInterval)interval
|
||||
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
|
||||
retry:(FBLPromiseRetryWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, which executes asynchronously on the given `queue`, or rejects with the same error after all
|
||||
retry attempts have been exhausted. On rejection, the `work` block is retried after the given
|
||||
delay `interval` and will continue to retry until the number of specified attempts have been
|
||||
exhausted or will bail early if the given condition is not met.
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param count Max number of retry attempts. The `work` block will be executed once if the specified
|
||||
count is less than or equal to zero.
|
||||
@param interval Time to wait before the next retry attempt.
|
||||
@param predicate Condition to check before the next retry attempt. The predicate block provides the
|
||||
the number of remaining retry attempts and the error that the promise was rejected
|
||||
with.
|
||||
@param work A block that executes asynchronously on the given `queue` and returns a value or an
|
||||
error used to resolve the promise.
|
||||
@return A new pending promise that fulfills with the same value as the promise returned from `work`
|
||||
block, or rejects with the same error after all retry attempts have been exhausted or if
|
||||
the given condition is not met.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
attempts:(NSInteger)count
|
||||
delay:(NSTimeInterval)interval
|
||||
condition:(nullable FBLPromiseRetryPredicateBlock)predicate
|
||||
retry:(FBLPromiseRetryWorkBlock)work NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise+Retry` operators.
|
||||
Usage: FBLPromise.retry(^id { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_RetryAdditions)
|
||||
|
||||
+ (FBLPromise * (^)(FBLPromiseRetryWorkBlock))retry FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, FBLPromiseRetryWorkBlock))retryOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise * (^)(NSInteger, NSTimeInterval, FBLPromiseRetryPredicateBlock __nullable,
|
||||
FBLPromiseRetryWorkBlock))retryAgain FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise * (^)(dispatch_queue_t, NSInteger, NSTimeInterval,
|
||||
FBLPromiseRetryPredicateBlock __nullable,
|
||||
FBLPromiseRetryWorkBlock))retryAgainOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
57
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Testing.h
generated
Normal file
57
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Testing.h
generated
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Waits for all scheduled promises blocks.
|
||||
|
||||
@param timeout Maximum time to wait.
|
||||
@return YES if all promises blocks have completed before the timeout and NO otherwise.
|
||||
*/
|
||||
FOUNDATION_EXTERN BOOL FBLWaitForPromisesWithTimeout(NSTimeInterval timeout) NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@interface FBLPromise<Value>(TestingAdditions)
|
||||
|
||||
/**
|
||||
Dispatch group for promises that is typically used to wait for all scheduled blocks.
|
||||
*/
|
||||
@property(class, nonatomic, readonly) dispatch_group_t dispatchGroup NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Properties to get the current state of the promise.
|
||||
*/
|
||||
@property(nonatomic, readonly) BOOL isPending NS_REFINED_FOR_SWIFT;
|
||||
@property(nonatomic, readonly) BOOL isFulfilled NS_REFINED_FOR_SWIFT;
|
||||
@property(nonatomic, readonly) BOOL isRejected NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Value the promise was fulfilled with.
|
||||
Can be nil if the promise is still pending, was resolved with nil or after it has been rejected.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) Value value NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Error the promise was rejected with.
|
||||
Can be nil if the promise is still pending or after it has been fulfilled.
|
||||
*/
|
||||
@property(nonatomic, readonly, nullable) NSError *error NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
63
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Then.h
generated
Normal file
63
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Then.h
generated
Normal file
@ -0,0 +1,63 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(ThenAdditions)
|
||||
|
||||
typedef id __nullable (^FBLPromiseThenWorkBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise which eventually gets resolved with resolution returned from `work`
|
||||
block: either value, error or another promise. The `work` block is executed asynchronously only
|
||||
when the receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with
|
||||
the same error.
|
||||
|
||||
@param work A block to handle the value that receiver was fulfilled with.
|
||||
@return A new pending promise to be resolved with resolution returned from the `work` block.
|
||||
*/
|
||||
- (FBLPromise *)then:(FBLPromiseThenWorkBlock)work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise which eventually gets resolved with resolution returned from `work`
|
||||
block: either value, error or another promise. The `work` block is executed asynchronously when the
|
||||
receiver is fulfilled. If receiver is rejected, the returned promise is also rejected with the same
|
||||
error.
|
||||
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to handle the value that receiver was fulfilled with.
|
||||
@return A new pending promise to be resolved with resolution returned from the `work` block.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
then:(FBLPromiseThenWorkBlock)work NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `then` operators.
|
||||
Usage: promise.then(^id(id value) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_ThenAdditions)
|
||||
|
||||
- (FBLPromise* (^)(FBLPromiseThenWorkBlock))then FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise* (^)(dispatch_queue_t, FBLPromiseThenWorkBlock))thenOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
57
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Timeout.h
generated
Normal file
57
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Timeout.h
generated
Normal file
@ -0,0 +1,57 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(TimeoutAdditions)
|
||||
|
||||
/**
|
||||
Waits for a promise with the specified `timeout`.
|
||||
|
||||
@param interval Time to wait in seconds.
|
||||
@return A new pending promise that gets either resolved with same resolution as the receiver or
|
||||
rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
|
||||
*/
|
||||
- (FBLPromise *)timeout:(NSTimeInterval)interval NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Waits for a promise with the specified `timeout`.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param interval Time to wait in seconds.
|
||||
@return A new pending promise that gets either resolved with same resolution as the receiver or
|
||||
rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
timeout:(NSTimeInterval)interval NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `timeout` operators.
|
||||
Usage: promise.timeout(...)
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_TimeoutAdditions)
|
||||
|
||||
- (FBLPromise* (^)(NSTimeInterval))timeout FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise* (^)(dispatch_queue_t, NSTimeInterval))timeoutOn FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Validate.h
generated
Normal file
60
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Validate.h
generated
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FBLPromise<Value>(ValidateAdditions)
|
||||
|
||||
typedef BOOL (^FBLPromiseValidateWorkBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Validates a fulfilled value or rejects the value if it can not be validated.
|
||||
|
||||
@param predicate An expression to validate.
|
||||
@return A new pending promise that gets either resolved with same resolution as the receiver or
|
||||
rejected with `FBLPromiseErrorCodeValidationFailure` error code in `FBLPromiseErrorDomain`.
|
||||
*/
|
||||
- (FBLPromise *)validate:(FBLPromiseValidateWorkBlock)predicate NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Validates a fulfilled value or rejects the value if it can not be validated.
|
||||
|
||||
@param queue A queue to dispatch on.
|
||||
@param predicate An expression to validate.
|
||||
@return A new pending promise that gets either resolved with same resolution as the receiver or
|
||||
rejected with `FBLPromiseErrorCodeValidationFailure` error code in `FBLPromiseErrorDomain`.
|
||||
*/
|
||||
- (FBLPromise *)onQueue:(dispatch_queue_t)queue
|
||||
validate:(FBLPromiseValidateWorkBlock)predicate NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `validate` operators.
|
||||
Usage: promise.validate(^BOOL(id value) { ... })
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_ValidateAdditions)
|
||||
|
||||
- (FBLPromise * (^)(FBLPromiseValidateWorkBlock))validate FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
- (FBLPromise * (^)(dispatch_queue_t, FBLPromiseValidateWorkBlock))validateOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
316
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Wrap.h
generated
Normal file
316
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise+Wrap.h
generated
Normal file
@ -0,0 +1,316 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Different types of completion handlers available to be wrapped with promise.
|
||||
*/
|
||||
typedef void (^FBLPromiseCompletion)(void) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseObjectCompletion)(id __nullable) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseErrorCompletion)(NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseObjectOrErrorCompletion)(id __nullable, NSError* __nullable)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseErrorOrObjectCompletion)(NSError* __nullable, id __nullable)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromise2ObjectsOrErrorCompletion)(id __nullable, id __nullable,
|
||||
NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseBoolCompletion)(BOOL) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseBoolOrErrorCompletion)(BOOL, NSError* __nullable) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseIntegerCompletion)(NSInteger) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseIntegerOrErrorCompletion)(NSInteger, NSError* __nullable)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseDoubleCompletion)(double) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseDoubleOrErrorCompletion)(double, NSError* __nullable)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Provides an easy way to convert methods that use common callback patterns into promises.
|
||||
*/
|
||||
@interface FBLPromise<Value>(WrapAdditions)
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with `nil` when completion handler is invoked.
|
||||
*/
|
||||
+ (instancetype)wrapCompletion:(void (^)(FBLPromiseCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with `nil` when completion handler is invoked.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapCompletion:(void (^)(FBLPromiseCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an object provided by completion handler.
|
||||
*/
|
||||
+ (instancetype)wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an object provided by completion handler.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapObjectCompletion:(void (^)(FBLPromiseObjectCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an error provided by completion handler.
|
||||
If error is `nil`, fulfills with `nil`, otherwise rejects with the error.
|
||||
*/
|
||||
+ (instancetype)wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an error provided by completion handler.
|
||||
If error is `nil`, fulfills with `nil`, otherwise rejects with the error.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapErrorCompletion:(void (^)(FBLPromiseErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an object provided by completion handler if error is `nil`.
|
||||
Otherwise, rejects with the error.
|
||||
*/
|
||||
+ (instancetype)wrapObjectOrErrorCompletion:
|
||||
(void (^)(FBLPromiseObjectOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an object provided by completion handler if error is `nil`.
|
||||
Otherwise, rejects with the error.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapObjectOrErrorCompletion:(void (^)(FBLPromiseObjectOrErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an error or object provided by completion handler. If error
|
||||
is not `nil`, rejects with the error.
|
||||
*/
|
||||
+ (instancetype)wrapErrorOrObjectCompletion:
|
||||
(void (^)(FBLPromiseErrorOrObjectCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an error or object provided by completion handler. If error
|
||||
is not `nil`, rejects with the error.
|
||||
*/
|
||||
+ (instancetype)onQueue:(dispatch_queue_t)queue
|
||||
wrapErrorOrObjectCompletion:(void (^)(FBLPromiseErrorOrObjectCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an array of objects provided by completion handler in order
|
||||
if error is `nil`. Otherwise, rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSArray*>*)wrap2ObjectsOrErrorCompletion:
|
||||
(void (^)(FBLPromise2ObjectsOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an array of objects provided by completion handler in order
|
||||
if error is `nil`. Otherwise, rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSArray*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrap2ObjectsOrErrorCompletion:(void (^)(FBLPromise2ObjectsOrErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping YES/NO.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping YES/NO.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapBoolCompletion:(void (^)(FBLPromiseBoolCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping YES/NO when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapBoolOrErrorCompletion:
|
||||
(void (^)(FBLPromiseBoolOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping YES/NO when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapBoolOrErrorCompletion:(void (^)(FBLPromiseBoolOrErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping an integer.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping an integer.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapIntegerCompletion:(void (^)(FBLPromiseIntegerCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping an integer when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapIntegerOrErrorCompletion:
|
||||
(void (^)(FBLPromiseIntegerOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping an integer when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapIntegerOrErrorCompletion:(void (^)(FBLPromiseIntegerOrErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping a double.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping a double.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapDoubleCompletion:(void (^)(FBLPromiseDoubleCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping a double when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)wrapDoubleOrErrorCompletion:
|
||||
(void (^)(FBLPromiseDoubleOrErrorCompletion handler))work NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
@param queue A queue to invoke the `work` block on.
|
||||
@param work A block to perform any operations needed to resolve the promise.
|
||||
@returns A promise that resolves with an `NSNumber` wrapping a double when error is `nil`.
|
||||
Otherwise rejects with the error.
|
||||
*/
|
||||
+ (FBLPromise<NSNumber*>*)onQueue:(dispatch_queue_t)queue
|
||||
wrapDoubleOrErrorCompletion:(void (^)(FBLPromiseDoubleOrErrorCompletion handler))work
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for `FBLPromise` `wrap` operators.
|
||||
Usage: FBLPromise.wrapCompletion(^(FBLPromiseCompletion handler) {...})
|
||||
*/
|
||||
@interface FBLPromise<Value>(DotSyntax_WrapAdditions)
|
||||
|
||||
+ (FBLPromise* (^)(void (^)(FBLPromiseCompletion)))wrapCompletion FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseCompletion)))wrapCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseObjectCompletion)))wrapObjectCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletion FBL_PROMISES_DOT_SYNTAX
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t, void (^)(FBLPromiseErrorCompletion)))wrapErrorCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseObjectOrErrorCompletion)))wrapObjectOrErrorCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseErrorOrObjectCompletion)))wrapErrorOrObjectCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSArray*>* (^)(void (^)(FBLPromise2ObjectsOrErrorCompletion)))
|
||||
wrap2ObjectsOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSArray*>* (^)(dispatch_queue_t, void (^)(FBLPromise2ObjectsOrErrorCompletion)))
|
||||
wrap2ObjectsOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseBoolCompletion)))wrapBoolCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseBoolOrErrorCompletion)))wrapBoolOrErrorCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseBoolOrErrorCompletion)))wrapBoolOrErrorCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseIntegerCompletion)))wrapIntegerCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseIntegerOrErrorCompletion)))
|
||||
wrapIntegerOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t, void (^)(FBLPromiseIntegerOrErrorCompletion)))
|
||||
wrapIntegerOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletion
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t,
|
||||
void (^)(FBLPromiseDoubleCompletion)))wrapDoubleCompletionOn
|
||||
FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(void (^)(FBLPromiseDoubleOrErrorCompletion)))
|
||||
wrapDoubleOrErrorCompletion FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise<NSNumber*>* (^)(dispatch_queue_t, void (^)(FBLPromiseDoubleOrErrorCompletion)))
|
||||
wrapDoubleOrErrorCompletionOn FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
93
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise.h
generated
Normal file
93
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromise.h
generated
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromiseError.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Promises synchronization construct in Objective-C.
|
||||
*/
|
||||
@interface FBLPromise<__covariant Value> : NSObject
|
||||
|
||||
/**
|
||||
Default dispatch queue used for `FBLPromise`, which is `main` if a queue is not specified.
|
||||
*/
|
||||
@property(class) dispatch_queue_t defaultDispatchQueue NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Creates a pending promise.
|
||||
*/
|
||||
+ (instancetype)pendingPromise NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Creates a resolved promise.
|
||||
|
||||
@param resolution An object to resolve the promise with: either a value or an error.
|
||||
@return A new resolved promise.
|
||||
*/
|
||||
+ (instancetype)resolvedWith:(nullable id)resolution NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Synchronously fulfills the promise with a value.
|
||||
|
||||
@param value An arbitrary value to fulfill the promise with, including `nil`.
|
||||
*/
|
||||
- (void)fulfill:(nullable Value)value NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Synchronously rejects the promise with an error.
|
||||
|
||||
@param error An error to reject the promise with.
|
||||
*/
|
||||
- (void)reject:(NSError *)error NS_REFINED_FOR_SWIFT;
|
||||
|
||||
+ (instancetype)new NS_UNAVAILABLE;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
@end
|
||||
|
||||
@interface FBLPromise<Value>()
|
||||
|
||||
/**
|
||||
Adds an object to the set of pending objects to keep strongly while the promise is pending.
|
||||
Used by the Swift wrappers to keep them alive until the underlying ObjC promise is resolved.
|
||||
|
||||
@param object An object to add.
|
||||
*/
|
||||
- (void)addPendingObject:(id)object NS_REFINED_FOR_SWIFT;
|
||||
|
||||
@end
|
||||
|
||||
#ifdef FBL_PROMISES_DOT_SYNTAX_IS_DEPRECATED
|
||||
#define FBL_PROMISES_DOT_SYNTAX __attribute__((deprecated))
|
||||
#else
|
||||
#define FBL_PROMISES_DOT_SYNTAX
|
||||
#endif
|
||||
|
||||
@interface FBLPromise<Value>(DotSyntaxAdditions)
|
||||
|
||||
/**
|
||||
Convenience dot-syntax wrappers for FBLPromise.
|
||||
Usage: FBLPromise.pending()
|
||||
FBLPromise.resolved(value)
|
||||
|
||||
*/
|
||||
+ (FBLPromise * (^)(void))pending FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
+ (FBLPromise * (^)(id __nullable))resolved FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
43
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromiseError.h
generated
Normal file
43
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromiseError.h
generated
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
FOUNDATION_EXTERN NSErrorDomain const FBLPromiseErrorDomain NS_REFINED_FOR_SWIFT;
|
||||
|
||||
/**
|
||||
Possible error codes in `FBLPromiseErrorDomain`.
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, FBLPromiseErrorCode) {
|
||||
/** Promise failed to resolve in time. */
|
||||
FBLPromiseErrorCodeTimedOut = 1,
|
||||
/** Validation predicate returned false. */
|
||||
FBLPromiseErrorCodeValidationFailure = 2,
|
||||
} NS_REFINED_FOR_SWIFT;
|
||||
|
||||
NS_INLINE BOOL FBLPromiseErrorIsTimedOut(NSError *error) NS_SWIFT_UNAVAILABLE("") {
|
||||
return error.domain == FBLPromiseErrorDomain &&
|
||||
error.code == FBLPromiseErrorCodeTimedOut;
|
||||
}
|
||||
|
||||
NS_INLINE BOOL FBLPromiseErrorIsValidationFailure(NSError *error) NS_SWIFT_UNAVAILABLE("") {
|
||||
return error.domain == FBLPromiseErrorDomain &&
|
||||
error.code == FBLPromiseErrorCodeValidationFailure;
|
||||
}
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
66
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromisePrivate.h
generated
Normal file
66
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromisePrivate.h
generated
Normal file
@ -0,0 +1,66 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+Testing.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Miscellaneous low-level private interfaces available to extend standard FBLPromise functionality.
|
||||
*/
|
||||
@interface FBLPromise<Value>()
|
||||
|
||||
typedef void (^FBLPromiseOnFulfillBlock)(Value __nullable value) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef void (^FBLPromiseOnRejectBlock)(NSError *error) NS_SWIFT_UNAVAILABLE("");
|
||||
typedef id __nullable (^__nullable FBLPromiseChainedFulfillBlock)(Value __nullable value)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
typedef id __nullable (^__nullable FBLPromiseChainedRejectBlock)(NSError *error)
|
||||
NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a pending promise.
|
||||
*/
|
||||
- (instancetype)initPending NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Creates a resolved promise.
|
||||
|
||||
@param resolution An object to resolve the promise with: either a value or an error.
|
||||
@return A new resolved promise.
|
||||
*/
|
||||
- (instancetype)initWithResolution:(nullable id)resolution NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Invokes `fulfill` and `reject` blocks on `queue` when the receiver gets either fulfilled or
|
||||
rejected respectively.
|
||||
*/
|
||||
- (void)observeOnQueue:(dispatch_queue_t)queue
|
||||
fulfill:(FBLPromiseOnFulfillBlock)onFulfill
|
||||
reject:(FBLPromiseOnRejectBlock)onReject NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
/**
|
||||
Returns a new promise which gets resolved with the return value of `chainedFulfill` or
|
||||
`chainedReject` blocks respectively. The blocks are invoked when the receiver gets either
|
||||
fulfilled or rejected. If `nil` is passed to either block arg, the returned promise is resolved
|
||||
with the same resolution as the receiver.
|
||||
*/
|
||||
- (FBLPromise *)chainOnQueue:(dispatch_queue_t)queue
|
||||
chainedFulfill:(FBLPromiseChainedFulfillBlock)chainedFulfill
|
||||
chainedReject:(FBLPromiseChainedRejectBlock)chainedReject NS_SWIFT_UNAVAILABLE("");
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
32
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromises.h
generated
Normal file
32
Pods/PromisesObjC/Sources/FBLPromises/include/FBLPromises.h
generated
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
Copyright 2018 Google Inc. All rights reserved.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
#import "FBLPromise+All.h"
|
||||
#import "FBLPromise+Always.h"
|
||||
#import "FBLPromise+Any.h"
|
||||
#import "FBLPromise+Async.h"
|
||||
#import "FBLPromise+Await.h"
|
||||
#import "FBLPromise+Catch.h"
|
||||
#import "FBLPromise+Delay.h"
|
||||
#import "FBLPromise+Do.h"
|
||||
#import "FBLPromise+Race.h"
|
||||
#import "FBLPromise+Recover.h"
|
||||
#import "FBLPromise+Reduce.h"
|
||||
#import "FBLPromise+Retry.h"
|
||||
#import "FBLPromise+Then.h"
|
||||
#import "FBLPromise+Timeout.h"
|
||||
#import "FBLPromise+Validate.h"
|
||||
#import "FBLPromise+Wrap.h"
|
||||
Reference in New Issue
Block a user