FBLPromise+Timeout.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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>(TimeoutAdditions)
  16. /**
  17. Waits for a promise with the specified `timeout`.
  18. @param interval Time to wait in seconds.
  19. @return A new pending promise that gets either resolved with same resolution as the receiver or
  20. rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
  21. */
  22. - (FBLPromise *)timeout:(NSTimeInterval)interval NS_SWIFT_UNAVAILABLE("");
  23. /**
  24. Waits for a promise with the specified `timeout`.
  25. @param queue A queue to dispatch on.
  26. @param interval Time to wait in seconds.
  27. @return A new pending promise that gets either resolved with same resolution as the receiver or
  28. rejected with `FBLPromiseErrorCodeTimedOut` error code in `FBLPromiseErrorDomain`.
  29. */
  30. - (FBLPromise *)onQueue:(dispatch_queue_t)queue
  31. timeout:(NSTimeInterval)interval NS_REFINED_FOR_SWIFT;
  32. @end
  33. /**
  34. Convenience dot-syntax wrappers for `FBLPromise` `timeout` operators.
  35. Usage: promise.timeout(...)
  36. */
  37. @interface FBLPromise<Value>(DotSyntax_TimeoutAdditions)
  38. - (FBLPromise* (^)(NSTimeInterval))timeout FBL_PROMISES_DOT_SYNTAX NS_SWIFT_UNAVAILABLE("");
  39. - (FBLPromise* (^)(dispatch_queue_t, NSTimeInterval))timeoutOn FBL_PROMISES_DOT_SYNTAX
  40. NS_SWIFT_UNAVAILABLE("");
  41. @end
  42. NS_ASSUME_NONNULL_END