GithubHelp home page GithubHelp logo

Comments (9)

agonzalezml avatar agonzalezml commented on August 12, 2024 1

Bad news

from vuex-persistedstate.

robinvdvleuten avatar robinvdvleuten commented on August 12, 2024 1

what about loading your "persisted state" asynchronously before creating the store instance?

from vuex-persistedstate.

alex-oleshkevich avatar alex-oleshkevich commented on August 12, 2024

+1, got same issue. Basically, this issue should be filed to vuex devs.

temporary created own plugin, which adds timeout to let vuex init modules.

import storage from 'localforage';
import merge from 'lodash.merge';

const KEY = 'vuex';

export default async(store) => {
    const savedState = await storage.getItem(KEY);
    setTimeout(f => {
        const newState = merge({}, store.state, savedState);
        store.replaceState(newState);
    }, 50);

    store.subscribe((mutation, state) => {
        storage.setItem(KEY, state);
    });
};

from vuex-persistedstate.

dhax avatar dhax commented on August 12, 2024

same issue here... any progress on this?

from vuex-persistedstate.

agonzalezml avatar agonzalezml commented on August 12, 2024

+1

from vuex-persistedstate.

robinvdvleuten avatar robinvdvleuten commented on August 12, 2024

Please read the note about localForage. A Vuex / Flux architecture and thereby this plugin cannot handle any asynchronous.

from vuex-persistedstate.

robinvdvleuten avatar robinvdvleuten commented on August 12, 2024

@agonzalezml please not that it's not an issue with this plugin, it's an issue in how you guys want to use "asynchronously" in your Vuex store.

from vuex-persistedstate.

disjfa avatar disjfa commented on August 12, 2024

Yup, i was also looking into this and how and where to trigger asynchronous mutations. But i can't find where to trigger those in vuex. It's not quite asynch, but just when we register new stores.

But you can easilly save local state of (your own) plugins using localstorrage, that's just some extra lines of code.

from vuex-persistedstate.

disjfa avatar disjfa commented on August 12, 2024

Thats not the issue. The issue is vuex logics.

  1. serup app store
    1.1 connect your persistedstate on main store state
  2. register plugin which resisters own module in the state.

And thus the persisted store is already registered and written so the modules does not know of the persisted state and will not be updated.

import store from './store'; // 1 and thus 1.1
Vue.use(timeline.plugin, { store, ... }); // 2

from vuex-persistedstate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.