question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support store structure changing

See original GitHub issue

For example, we have a user vuex-module with this state:

{
  token: '',
  name: '',
}

The state is saved in local storage.

createMultiTabState({ statesPaths: ['user']  })
{ "token": "tokenstring", "name": "Jonn Smith" }

But some reasons we change state object to:

{
  name: '',
  auth: {
    token: ''
  },
}

And now want to keep in storage only user.auth path.

createMultiTabState({ statesPaths: ['use.auth']  })

Reload page - and it removes the state auth key! The app is broken.

client.js?06a0:97 TypeError: Cannot read property 'token' of undefined

This error happens in the getter:

{
  isAuthenticated(state) {
    return !!state.auth.token;
  },
}

And yes, I can fix it:

{
  isAuthenticated(state) {
    return !!state.auth && !!state.auth.token;
  },
}

But maybe It will be better if vuex-multi-tab-state will respect the default state and do not override it if the path does not exist in the local storage. And do not create top-level state properties if they were removed from the default state. What do you think?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
entioentiocommented, Aug 23, 2021

Random: I can imagine that for some cases it’d be actually better to store the whole store behind a version. Then by initialization you’d be able to migrate existing data.

2reactions
joshuabylercommented, May 21, 2021

@andrey-hohlov What I did to get around this at least for the people using the application was on login

window.localStorage.removeItem('vuex-multi-tab')

For myself while developing on localhost I just had to manually clear it

Read more comments on GitHub >

github_iconTop Results From Across the Web

Structure Changes that Drive Change - Prosci
Structural changes associated with improvement systems - like adopting a new operational methodology - are changes where change management is often ignored.
Read more >
How To Successfully Change Your Organizational Structure
1. Understanding Your Current Problems And Goals. When planning changes, you must fully understand your current problems and your intended ...
Read more >
Organizational Structure and Culture Change
For example, a supervisor went from managing five or more stores in 1988 to 20 or more stores in 1991. Managers also focused...
Read more >
Six Steps to Effective Organizational Change Management
Providing a support structure is essential to assist employees to emotionally and practically adjust to the change and to build proficiency of behaviors...
Read more >
Set Up a Store Pages Structure on Facebook
To set up stores on Facebook: Open Store Locations in Business Manager. Select the Page in the top menu for which you want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found