No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    How to use vuex store without access to vue instance?

    Framework
    5
    5
    2472
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      Fragster last edited by

      E.g in beforeRouteEnter hook?
      I try make it in this way (store is dynamically filled in boot folder):

      import StoreFunction from 'store';
      const store = StoreFunction();
      ...
      export default {
      
        beforeRouteEnter(to, from, next) {
          if (store.state.catalog.loading) next({to: 'routename'});
          else next();
        }
      

      but it causes an error “do not mutate vuex store state outside mutation handlers.”

      to fix it, I change store/index.js to return store instance instead of function, and it works. But I’m worrying about possible side effects of this ‘fix’.

      //export default function(/* { ssrContext } */) {
        export default new Vuex.Store({
      

      Is this right fix, or there is another ‘proper’ way in my case?

      T 1 Reply Last reply Reply Quote 0
      • T
        tof06 @Fragster last edited by

        @Fragster
        It should be confirmed by a more a experienced dev than me, but if you’re not building for SSR mode, you can export directly the Store instance like you did.

        What I’ve done is something similar :

        
        const Store = new Vuex.Store({...})
        
        export { Store }
        export default function (/* ssrContext */) {
          return Store
        }
        

        This way, I export both the function (default export), and the instance
        And, when I need to access Store outside component, I just import { Store } from 'src/store'

        1 Reply Last reply Reply Quote 0
        • B
          blakeyuk last edited by

          Excellent! Two years later, and still useful. Thanks @tof06

          1 Reply Last reply Reply Quote 0
          • D
            devinsmith0444 last edited by

            Accounting tools can be of great assistance, so as totackle out different processes and tasks. In today’s post, we will be learning the procedure to access different accounting tools in QuickBooks desktop enterprise. Accounting tools can be a saviour in majority of cases.

            To know more about accessing accounting tools in QuickBooks desktop enterprise, make sure to read this post till the end.

            1 Reply Last reply Reply Quote -2
            • A
              alexmalcova last edited by

              Simple Method To Find Target balance of gift cards The balance of your Target Gift Card is * Target GiftCards can be used at any Target store or online at Target.com to purchase various merchandise
              https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalance/
              https://sites.google.com/ledgercomstarts.com/ledgercomstarts/
              https://sites.google.com/venmologinus.com/venmologins/
              https://sites.google.com/view/venmol0gin/
              https://sites.google.com/view/walmartgiftcardbalancecheckk/
              https://sites.google.com/view/url-amazon-com-redeem/
              https://sites.google.com/view/targetgiftcardbalancee/
              https://sites.google.com/view/vanillagiftcardbalancee/
              https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalances/
              https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalance/
              https://sites.google.com/vanillaegiftcardbalance.com/vanillaegiftcardbalance/
              https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalancecheck/
              https://sites.google.com/vanillaegiftcardbalance.com/vanillagiftcardbalances/
              https://sites.google.com/targetgiftcardsbalance.com/targetcomcheckbalance/
              https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalancee/
              https://sites.google.com/targetgiftcardsbalance.com/targetgiftcardbalancecheck/
              https://sites.google.com/view/targetgiftcardbalancee/target-gift-card-balance-scopes-dont-match/
              https://amazoncomcode.onepage.website/
              https://sites.google.com/view/spectrumemailloginn/
              https://sites.google.com/view/ebaycustomerservicee/
              https://sites.google.com/ledgercomstarts.com/ledgercomstart/
              https://sites.google.com/view/dunkindonutsgiftcardbalances/
              https://sites.google.com/view/amazoncomredeemgift/

              1 Reply Last reply Reply Quote 0
              • First post
                Last post