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

Commit 3da4dae

Browse files
committed
Updated README for new static methods.
1 parent f75f7b0 commit 3da4dae

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,39 @@ export default class App extends Component<{}> {
213213
}
214214
```
215215

216+
## Static Methods
217+
218+
The CacheableImage class returned by React Native Image Cache HOC includes a couple of static methods for convenience.
219+
220+
**CacheableImage.cacheFile(url, permanent)**
221+
222+
Use this method if you need to download a file to the local filesystem prior to rendering \<CacheableImage\> for some reason (perhaps to pre-warm the local cache). If calling this method repeatedly to cache a long list of files, be sure to use a queue and limit concurrency so your app performance does not suffer.
223+
224+
```js
225+
import imageCacheHoc from 'react-native-image-cache-hoc';
226+
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.
235+
```
236+
237+
**CacheableImage.flush()**
238+
239+
Delete all locally stored image files created by react-native-image-cache-hoc (cache AND permanent). Calling this method will cause a performance hit on your app until the local files are rebuilt.
240+
241+
```js
242+
import imageCacheHoc from 'react-native-image-cache-hoc';
243+
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+
```
216249

217250
## Jest Test Support
218251

0 commit comments

Comments
 (0)