FBLPromisePrivate.h 2.4 KB

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