Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 50ac125

Browse files
committed
Clarifying promise examples in readme.
1 parent c6d1ff1 commit 50ac125

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,18 @@ Use this method if you need to download a file to the local filesystem prior to
224224
```js
225225
import imageCacheHoc from 'react-native-image-cache-hoc';
226226
const CacheableImage = imageCacheHoc(Image);
227-
CacheableImage.cacheFile('https://i.redd.it/17ymhqwgbswz.jpg');
228-
229-
// The https://i.redd.it/17ymhqwgbswz.jpg remote file is now saved to local fs.
230-
// Since permanent was not set, this file is subject to cache pruning.
231-
232-
CacheableImage.cacheFile('https://i.redd.it/hhhim0kc5swz.jpg', true);
233-
234-
// The https://i.redd.it/hhhim0kc5swz.jpg remote file is now saved to local fs permanently.
227+
CacheableImage.cacheFile('https://i.redd.it/17ymhqwgbswz.jpg')
228+
.then( localFileInfo => {
229+
console.log(localFileInfo);
230+
// The https://i.redd.it/17ymhqwgbswz.jpg remote file is now saved to local fs.
231+
// Since permanent was not set, this file is subject to cache pruning.
232+
});
233+
234+
CacheableImage.cacheFile('https://i.redd.it/hhhim0kc5swz.jpg', true)
235+
.then( localFileInfo => {
236+
console.log(localFileInfo);
237+
// The https://i.redd.it/hhhim0kc5swz.jpg remote file is now saved to local fs permanently.
238+
});
235239
```
236240

237241
**CacheableImage.flush()**
@@ -241,10 +245,12 @@ Delete all locally stored image files created by react-native-image-cache-hoc (c
241245
```js
242246
import imageCacheHoc from 'react-native-image-cache-hoc';
243247
const CacheableImage = imageCacheHoc(Image);
244-
CacheableImage.flush();
245-
246-
// All local filles created by 'react-native-image-cache-hoc' are now destroyed.
247-
// They will be rebuilt by future <CacheableImage> renders.
248+
CacheableImage.flush()
249+
.then( flushResults => {
250+
console.log(flushResults);
251+
// All local filles created by 'react-native-image-cache-hoc' are now destroyed.
252+
// They will be rebuilt by future <CacheableImage> renders.
253+
});
248254
```
249255

250256
## Jest Test Support

0 commit comments

Comments
 (0)