FIRStorageObservableTask

@interface FIRStorageObservableTask : FIRStorageTask

Extends FIRStorageTask to provide observable semantics such as adding and removing observers. Observers produce a FIRStorageHandle, which is used to keep track of and remove specific observers at a later date. This class is currently not thread safe and can only be called on the main thread.

  • Observes changes in the upload status: Resume, Pause, Progress, Success, and Failure. - parameter: status The FIRStorageTaskStatus change to observe. - parameter: handler A callback that fires every time the status event occurs, returns a FIRStorageTaskSnapshot containing the state of the task. - returns: A task handle that can be used to remove the observer at a later date.

    Declaration

    Swift

    func observe(_ status: FIRStorageTaskStatus, handler: @escaping (FIRStorageTaskSnapshot) -> Void) -> String

    Objective-C

    - (nonnull FIRStorageHandle)
    observeStatus:(FIRStorageTaskStatus)status
          handler:(nonnull void (^)(FIRStorageTaskSnapshot *_Nonnull))handler;

    Parameters

    status

    The FIRStorageTaskStatus change to observe.

    handler

    A callback that fires every time the status event occurs, returns a FIRStorageTaskSnapshot containing the state of the task.

    Return Value

    A task handle that can be used to remove the observer at a later date.

  • Removes the single observer with the provided handle. - parameter: handle The handle of the task to remove.

    Declaration

    Swift

    func removeObserver(withHandle handle: String)

    Objective-C

    - (void)removeObserverWithHandle:(nonnull FIRStorageHandle)handle;

    Parameters

    handle

    The handle of the task to remove.

  • Removes all observers for a single status. - parameter: status A FIRStorageTaskStatus to remove listeners for.

    Declaration

    Swift

    func removeAllObservers(for status: FIRStorageTaskStatus)

    Objective-C

    - (void)removeAllObserversForStatus:(FIRStorageTaskStatus)status;

    Parameters

    status

    A FIRStorageTaskStatus to remove listeners for.

  • Removes all observers.

    Declaration

    Swift

    func removeAllObservers()

    Objective-C

    - (void)removeAllObservers;