Files
RxFirebase/Sources/Storage/FIRStorageObservableTask+Rx.swift
Arnaud Dorgans 8ca348fc0f storage fixes
2018-07-24 00:08:45 +02:00

31 lines
939 B
Swift

//
// FIRStorageObservableTask+Rx.swift
// RxFirebase
//
// Created by Arnaud Dorgans on 19/07/2018.
//
import UIKit
import RxSwift
import FirebaseStorage
extension Reactive where Base: StorageObservableTask {
/**
* Observes changes in the upload status: Resume, Pause, Progress, Success, and Failure.
* @param status The FIRStorageTaskStatus change to observe.
* @param handler A callback that fires every time the status event occurs,
* returns a FIRStorageTaskSnapshot containing the state of the task.
*/
public func observe(_ status: StorageTaskStatus) -> Observable<StorageTaskSnapshot> {
return Observable.create { observer in
let handle = self.base.observe(status) { snapshot in
observer.onNext(snapshot)
}
return Disposables.create {
self.base.removeObserver(withHandle: handle)
}
}
}
}