better-queue-persistent-store-layer
v1.0.1
Published
A pluggable persistent store layer for better-queue
Downloads
7
Maintainers
Readme
Better Queue - Persistent Store Layer
Example with localStorage
// create a storage layer with sync or async load and save methods with your preferred persistence method
const Store = ('better-queue-persistent-store-layer');
const Queue = ('better-queue');
class Storage {
load(defaultValue = null) {
const value = localStorage.getItem('queue');
return (value && JSON.parse(value)) || defaultValue;
}
save(data) {
localStorage.setItem('queue', JSON.stringify(data));
}
};
const q = new Queue(fn, {
store: new Store(new Storage())
});