resouce-loader
v1.0.1
Published
a generic resource loader to load remote resource and cache in local prestige storage
Downloads
2
Readme
ResourceLoader
a generic resource loader to load remote resource and cache in local prestige storage
Install
npm install -s resource-loader
yarn add resource-loader
Usage
import ResourceLoader from "resource-loader";
const config = {
fetchRemote: key => remoteServer.load(key),
fetchLocal: key => localStorage.load(key),
saveLocal: (key, data) => localStorage.save(key, data),
};
const resLoader = new ResourceLoader<string>(config);
resLoader.load("key")....
ResourceLoader config
| name | type | description | | ----------- | ----------------------------- | ----------------------------- | | fetchRemote | (string) => Promise | fetch data from remote server | | fetchLocal | (string) => Promise | fetch data from local storage | | saveLocal | (string) => Promise | store data to local storage |