Caches data in a predetermined range.
npm install mag-data-cacher
Add the constructor to the scope:
var DataCacher = require('mag-data-cacher');
Create instance with custom config:
var dataCacher = new DataCacher({
pageSize: 7,
cacheSize: 2,
request: {},
getter: function ( callback, config, count ) {
//
}
});
To check and get data for next page:
var callback = function ( error, receivedData ) {
console.log(error);
console.log(receivedData);
};
dataCacher.checkPrev(callback);
To check and get data for previous page:
dataCacher.checkNext(callback);
To check and get data for 1st page:
dataCacher.goHome(callback);
To check and get data for last page:
dataCacher.goEnd(callback);
To refresh data:
dataCacher.refreshData(callback);
If you have any problems or suggestions please open an issue according to the contribution rules.
mag-data-cacher
is released under the MIT License.