mirror of
https://github.com/zoriya/react-native-background-downloader.git
synced 2026-06-06 19:22:14 +00:00
fix safeguard functions
This commit is contained in:
+4
-4
@@ -57,24 +57,24 @@ export default class DownloadTask {
|
|||||||
|
|
||||||
onBegin ({ expectedBytes, headers }) {
|
onBegin ({ expectedBytes, headers }) {
|
||||||
this.state = 'DOWNLOADING'
|
this.state = 'DOWNLOADING'
|
||||||
this?.beginHandler({ expectedBytes, headers })
|
this.beginHandler?.({ expectedBytes, headers })
|
||||||
}
|
}
|
||||||
|
|
||||||
onProgress (percent, bytesWritten, totalBytes) {
|
onProgress (percent, bytesWritten, totalBytes) {
|
||||||
this.percent = percent
|
this.percent = percent
|
||||||
this.bytesWritten = bytesWritten
|
this.bytesWritten = bytesWritten
|
||||||
this.totalBytes = totalBytes
|
this.totalBytes = totalBytes
|
||||||
this?.progressHandler(percent, bytesWritten, totalBytes)
|
this.progressHandler?.(percent, bytesWritten, totalBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
onDone ({ location }) {
|
onDone ({ location }) {
|
||||||
this.state = 'DONE'
|
this.state = 'DONE'
|
||||||
this?.doneHandler({ location })
|
this.doneHandler?.({ location })
|
||||||
}
|
}
|
||||||
|
|
||||||
onError (error, errorCode) {
|
onError (error, errorCode) {
|
||||||
this.state = 'FAILED'
|
this.state = 'FAILED'
|
||||||
this?.errorHandler(error, errorCode)
|
this.errorHandler?.(error, errorCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
pause () {
|
pause () {
|
||||||
|
|||||||
Reference in New Issue
Block a user