FIRStorageObservableTask.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 FIRStorageReference;
  19. @class FIRStorageTaskSnapshot;
  20. /**
  21. * Extends FIRStorageTask 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. NS_SWIFT_NAME(StorageObservableTask)
  27. @interface FIRStorageObservableTask : FIRStorageTask
  28. /**
  29. * Observes changes in the upload status: Resume, Pause, Progress, Success, and Failure.
  30. * @param status The FIRStorageTaskStatus change to observe.
  31. * @param handler A callback that fires every time the status event occurs,
  32. * returns a FIRStorageTaskSnapshot containing the state of the task.
  33. * @return A task handle that can be used to remove the observer at a later date.
  34. */
  35. - (FIRStorageHandle)observeStatus:(FIRStorageTaskStatus)status
  36. handler:(void (^)(FIRStorageTaskSnapshot *snapshot))handler;
  37. /**
  38. * Removes the single observer with the provided handle.
  39. * @param handle The handle of the task to remove.
  40. */
  41. - (void)removeObserverWithHandle:(FIRStorageHandle)handle;
  42. /**
  43. * Removes all observers for a single status.
  44. * @param status A FIRStorageTaskStatus to remove listeners for.
  45. */
  46. - (void)removeAllObserversForStatus:(FIRStorageTaskStatus)status;
  47. /**
  48. * Removes all observers.
  49. */
  50. - (void)removeAllObservers;
  51. @end
  52. NS_ASSUME_NONNULL_END