|
@@ -194,12 +194,37 @@ function fetch(...args:any):Promise {
|
194
|
194
|
// extend Promise object, add `progress`, `uploadProgress`, and `cancel`
|
195
|
195
|
// method for register progress event handler and cancel request.
|
196
|
196
|
// Add second parameter for performance purpose #140
|
197
|
|
- promise.progress = (fn, interval:number=250, count:number=-1) => {
|
|
197
|
+ // When there's only one argument pass to this method, use default `interval`
|
|
198
|
+ // and `count`, otherwise use the given on.
|
|
199
|
+ // TODO : code refactor, move `uploadProgress` and `progress` to StatefulPromise
|
|
200
|
+ promise.progress = (...args) => {
|
|
201
|
+ let interval = 250
|
|
202
|
+ let count = -1
|
|
203
|
+ let fn = () => {}
|
|
204
|
+ if(args.length === 2) {
|
|
205
|
+ interval = args[0].interval
|
|
206
|
+ interval = args[0].count
|
|
207
|
+ fn = args[1]
|
|
208
|
+ }
|
|
209
|
+ else {
|
|
210
|
+ fn = args[0]
|
|
211
|
+ }
|
198
|
212
|
promise.onProgress = fn
|
199
|
213
|
RNFetchBlob.enableProgressReport(taskId, interval, count)
|
200
|
214
|
return promise
|
201
|
215
|
}
|
202
|
|
- promise.uploadProgress = (fn, interval:number=250, count:number=-1) => {
|
|
216
|
+ promise.uploadProgress = (...args) => {
|
|
217
|
+ let interval = 250
|
|
218
|
+ let count = -1
|
|
219
|
+ let fn = () => {}
|
|
220
|
+ if(args.length === 2) {
|
|
221
|
+ interval = args[0].interval
|
|
222
|
+ interval = args[0].count
|
|
223
|
+ fn = args[1]
|
|
224
|
+ }
|
|
225
|
+ else {
|
|
226
|
+ fn = args[0]
|
|
227
|
+ }
|
203
|
228
|
promise.onUploadProgress = fn
|
204
|
229
|
RNFetchBlob.enableUploadProgressReport(taskId, interval, count)
|
205
|
230
|
return promise
|