FIRStorageObservableTask.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FIRStorageSwiftNameSupport.h"
  17. #import "FIRStorageTask.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. @class FIRStorageReference;
  20. @class FIRStorageTaskSnapshot;
  21. /**
  22. * Extends FIRStorageTask to provide observable semantics such as adding and removing observers.
  23. * Observers produce a FIRStorageHandle, which is used to keep track of and remove specific
  24. * observers at a later date.
  25. * This class is currently not thread safe and can only be called on the main thread.
  26. */
  27. FIR_SWIFT_NAME(StorageObservableTask)
  28. @interface FIRStorageObservableTask : FIRStorageTask
  29. /**
  30. * Observes changes in the upload status: Resume, Pause, Progress, Success, and Failure.
  31. * @param status The FIRStorageTaskStatus change to observe.
  32. * @param handler A callback that fires every time the status event occurs,
  33. * returns a FIRStorageTaskSnapshot containing the state of the task.
  34. * @return A task handle that can be used to remove the observer at a later date.
  35. */
  36. - (FIRStorageHandle)observeStatus:(FIRStorageTaskStatus)status
  37. handler:(void (^)(FIRStorageTaskSnapshot *snapshot))handler;
  38. /**
  39. * Removes the single observer with the provided handle.
  40. * @param handle The handle of the task to remove.
  41. */
  42. - (void)removeObserverWithHandle:(FIRStorageHandle)handle;
  43. /**
  44. * Removes all observers for a single status.
  45. * @param status A FIRStorageTaskStatus to remove listeners for.
  46. */
  47. - (void)removeAllObserversForStatus:(FIRStorageTaskStatus)status;
  48. /**
  49. * Removes all observers.
  50. */
  51. - (void)removeAllObservers;
  52. @end
  53. NS_ASSUME_NONNULL_END