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

    Vuex use Quasar Loading

    Help
    3
    4
    1382
    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.
    • S
      synbits last edited by synbits

      Hello,

      I have modules in a Vuex store.
      During the mutations I have states changing, with a pending state to show a Loading spinner.
      Where do I listen to the state to change and show or hide the loading?

      In any .vue file? How?
      Or can I do it inside the vuex module?

      This is my idea now inside a .vue file:

      <script>
      import { Loading } from 'quasar'
      export default {
        name: 'PageLogin',
        data () {
        	return {
        		email:"",
        		password: ""
        	}
        },
        watch: {
          runLoading: () => {
            if(this.runLoading){
            	Loading.show()
            }else{
            	Loading.hide()
            }
          }
        },
        methods: {
        	login () {
        		console.log(this.$store)
        		this.$store.dispatch("auth/doLogin", {
        			email: this.email,
        			password: this.password
        		}).then(() => {
        			this.$router.push("/")
        		}).catch((res) => {
        			console.log(res)
        		})
        	}
        },
        computed: {
          runLoading () {
            return this.$store.state.auth.pending
          }
        }
      }
      </script>
      
      1 Reply Last reply Reply Quote 0
      • E
        eugene last edited by

        https://github.com/quasarframework/quasar-play/blob/master/src/components/showcase/progress/loading.vue
        this is a good example of how to do it from within a .vue module

        1 Reply Last reply Reply Quote 0
        • benoitranque
          benoitranque last edited by

          Vuex commits must not be async, that is what actions are for. You can pass this as part of the payload and access the global vue instance from there

          1 Reply Last reply Reply Quote 0
          • S
            synbits last edited by

            Ok, roger that!

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