Skip to content

Instantly share code, notes, and snippets.

@idoshamun
Last active Jun 17, 2019
Embed
What would you like to do?
Optimistic Offline-First Apps With Vuex
import localForage from 'localforage';
const store = localForage.createInstance({
name: 'app',
});
const mapStateForCache = (state) => {
// Your business logic here
};
export const setState = (state) => {
const cachedState = mapStateForCache(state);
return store.setItem('state', cachedState);
};
export const getState = () => store.getItem('state');
export const deleteState = () => store.removeItem('state');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment