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 { setState } from './storage';
const shouldSkipCache = (mutation) => {
// Your business logic here
};
const plugin = (store) => {
store.subscribe((mutation, state) => {
if (!shouldSkipCache(mutation)) {
setState(state).catch(err => console.warn('failed to cache state', err));
}
});
};
export default plugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment