Browse Source

Release fetch resource

Ben Hsieh 7 years ago
parent
commit
664a91c246
2 changed files with 13 additions and 0 deletions
  1. 8
    0
      src/class/StatefulPromise.js
  2. 5
    0
      src/index.js

+ 8
- 0
src/class/StatefulPromise.js View File

@@ -0,0 +1,8 @@
1
+// Copyright 2016 wkh237@github. All rights reserved.
2
+// Use of this source code is governed by a MIT-style license that can be
3
+// found in the LICENSE file.
4
+// @flow
5
+
6
+export default class StatefulPromise extends Promise {
7
+
8
+}

+ 5
- 0
src/index.js View File

@@ -16,6 +16,7 @@ import type {
16 16
   RNFetchBlobStream,
17 17
   RNFetchBlobResponseInfo
18 18
 } from './types'
19
+import StatefulPromise from './class/StatefulPromise.js'
19 20
 import fs from './fs'
20 21
 import getUUID from './utils/uuid'
21 22
 import base64 from 'base-64'
@@ -167,6 +168,10 @@ function fetch(...args:any):Promise {
167 168
       subscription.remove()
168 169
       subscriptionUpload.remove()
169 170
       stateEvent.remove()
171
+      delete promise['progress']
172
+      delete promise['uploadProgress']
173
+      delete promise['stateChange']
174
+      delete promise['cancel']
170 175
 
171 176
       if(err)
172 177
         reject(new Error(err, respInfo))