1.0.7 • Published 7 years ago

web-local-cache v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
7 years ago

web-local-cache

cache data with localStorage

API

import LocalCache from 'web-local-cache';

// register
const data_key = {
    url: 'https://xx.xx.json',
    header: {},
    data: {},
    success: (resp) => {
        return resp.data;
    },
    error: (e) => {
        console.log(e);
    },
    version: '1.0.0' //version format must be x.x.x
};

const UniqueData = LocalCache.register('unique', {
    data_key
});

// get
const { data_key } = UniqueData;
data_key.then((data) => {
    console.log(data);
});

// clear all
LocalCache.clear('unique');

// clear property
UniqueData.clear('data_key');

We used the native fetch method as default to get data. If you want to change fetch method, you can pass a fetch get method which will return a standard promise object as the third argument:

LocalCache.register('unique', {
   // data options
}, fetchGetMethod);
1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.4-rc1

7 years ago

1.0.4-rc

7 years ago

1.0.4-beta

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago