FBLPromise+Always.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. Copyright 2018 Google Inc. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at:
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. #import "FBLPromise.h"
  14. NS_ASSUME_NONNULL_BEGIN
  15. @interface FBLPromise<Value>(AlwaysAdditions)
  16. typedef void (^FBLPromiseAlwaysWorkBlock)(void) NS_SWIFT_UNAVAILABLE("");
  17. /**
  18. @param work A block that always executes, no matter if the receiver is rejected or fulfilled.
  19. @return A new pending promise to be resolved with same resolution as the receiver.
  20. */
  21. - (FBLPromise *)always:(FBLPromiseAlwaysWorkBlock)work NS_SWIFT_UNAVAILABLE("");
  22. /**
  23. @param queue A queue to dispatch on.
  24. @param work A block that always executes, no matter if the receiver is rejected or fulfilled.
  25. @return A new pending promise to be resolved with same resolution as the receiver.
  26. */
  27. - (FBLPromise *)onQueue:(dispatch_queue_t)queue
  28. always:(FBLPromiseAlwaysWorkBlock)work NS_REFINED_FOR_SWIFT;
  29. @end
  30. /**
  31. Convenience dot-syntax wrappers for `FBLPromise` `always` operators.
  32. Usage: promise.always(^{...})
  33. */
  34. @interface FBLPromise<Value>(DotSyntax_AlwaysAdditions)
  35. - (FBLPromise* (^)(FBLPromiseAlwaysWorkBlock))always FBL_PROMISES_DOT_SYNTAX
  36. NS_SWIFT_UNAVAILABLE("");
  37. - (FBLPromise* (^)(dispatch_queue_t, FBLPromiseAlwaysWorkBlock))alwaysOn FBL_PROMISES_DOT_SYNTAX
  38. NS_SWIFT_UNAVAILABLE("");
  39. @end
  40. NS_ASSUME_NONNULL_END