FIRStorageObservableTask.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 "FIRStorageTask.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. @class FIRIMPLStorageReference;
  19. @class FIRIMPLStorageTaskSnapshot;
  20. /**
  21. * Extends FIRIMPLStorageTask to provide observable semantics such as adding and removing observers.
  22. * Observers produce a FIRStorageHandle, which is used to keep track of and remove specific
  23. * observers at a later date.
  24. * This class is currently not thread safe and can only be called on the main thread.
  25. */
  26. @interface FIRIMPLStorageObservableTask : FIRIMPLStorageTask
  27. /**
  28. * Observes changes in the upload status: Resume, Pause, Progress, Success, and Failure.
  29. * @param status The FIRIMPLStorageTaskStatus change to observe.
  30. * @param handler A callback that fires every time the status event occurs,
  31. * returns a FIRIMPLStorageTaskSnapshot containing the state of the task.
  32. * @return A task handle that can be used to remove the observer at a later date.
  33. */
  34. - (FIRStorageHandle)observeStatus:(FIRIMPLStorageTaskStatus)status
  35. handler:(void (^)(FIRIMPLStorageTaskSnapshot *snapshot))handler;
  36. /**
  37. * Removes the single observer with the provided handle.
  38. * @param handle The handle of the task to remove.
  39. */
  40. - (void)removeObserverWithHandle:(FIRStorageHandle)handle;
  41. /**
  42. * Removes all observers for a single status.
  43. * @param status A FIRIMPLStorageTaskStatus to remove listeners for.
  44. */
  45. - (void)removeAllObserversForStatus:(FIRIMPLStorageTaskStatus)status;
  46. /**
  47. * Removes all observers.
  48. */
  49. - (void)removeAllObservers;
  50. @end
  51. NS_ASSUME_NONNULL_END