Skip to content

Instantly share code, notes, and snippets.

Created Oct 8, 2018
What would you like to do?
Optimistic Offline-First Apps With Vuex
import Vue from 'vue';
import Vuex from 'vuex';
import cache from './plugins/cache';
import sync from './plugins/sync';
export default new Vuex.Store({
state: {
initialized: false,
mutations: {
loadFromCache(state, cached) {
if (cached) {
Object.keys(cached).forEach((key) => {
state[key] = Object.assign({}, state[key], cached[key]);
state.initialized = true;
plugins: [cache, sync],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment