Last active
June 17, 2019 14:07
-
-
Save idoshamun/33b925982642858c5541983db987efbe to your computer and use it in GitHub Desktop.
Optimistic Offline-First Apps With Vuex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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