项目
在 GitHub 查看
reactnativecn/react-native-http-cache
关于
Native module to control react native http cache
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文React Native http cache control for both fetch/XMLHttpRequest and ImageView
- iOS
- Android
Installation
$ npm install react-native-http-cache --save
iOS: Linking in your XCode project
- Link
react-native-http-cachelibrary from yournode_modules/react-native-http-cache/iosfolder like its described here. Don't forget to add it to "Build Phases" of project.
Android: Linking to your gradle Project
- Add following lines into
android/settings.gradle
include ':RCTHttpCache'
project(':RCTHttpCache').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-http-cache/android')
- Add following lines into your
android/app/build.gradlein sectiondependencies
...
dependencies {
...
compile project(':RCTHttpCache') // Add this line only.
}
- Add following lines into
MainApplication.java
...
import cn.reactnative.httpcache.HttpCachePackage;
// Add this line before public class MainApplication
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
protected boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new HttpCachePackage(), // Add this line
new MainReactPackage()
);
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
}
- Add these lines to 'proguard-rules.pro' if you need to minify your java code:
-keep class com.facebook.cache.disk.DiskStorageCache {
private boolean maybeUpdateFileCacheSize();
}
JavaScript: import all and invoke!
import * as CacheManager from 'react-native-http-cache';
// invoke API directly when in need
CacheManager.clear();
API Documentation
clear()
Clear cache for all type.
Return a promise which indicate the clear state.
getSize()
Get cache size for all type.
Return a promise that contain the cache size(in bytes).
clearHttpCache()
Clear cache for fetch/ajax only.
Return a promise which indicate the clear state.
getHttpCacheSize()
Get cache size for fetch/ajax only.
Return a promise that contain the cache size(in bytes).
clearImageCache()
Clear cache for ImageView only.
Return a promise which indicate the clear state.
getImageCacheSize()
Get cache size for ImageView only.
Return a promise that contain the cache size(in bytes).
Authors
- Deng Yun from React-Native-CN
- Lv Bingru from React-Native-CN
探索相关项目
加载中…