Skip to content

Toggle changing AppState #9326

May 18, 2021 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

u're trying to mutate the state directly.
just to be clear, what is being mapped, is the settings, not the property called isUserAllowed, so update that, will not trigger the set.

so, u would do something like:

    const isUserAllowed = computed({
      get: () => root.$store.getters['app/settings'].isUserAllowed,
      set: val => { root.$store.commit('app/setSettings', { isUserAllowed: value })  }
    });

since I'm spreading for the 4 winds to not use vuex, here the converted version of your module:

import { reactive } from 'vue'

export interface AppSettings {
  isUserAllowed: boolean;
}

export interface AppState {
  isBusy: boolean,
  settings: AppSettings
}

let _state: AppState | null

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JokerMartini
Comment options

@TobyMosque
Comment options

@JokerMartini
Comment options

Answer selected by JokerMartini
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants