Coder Social home page Coder Social logo

Comments (4)

ankurk91 avatar ankurk91 commented on May 26, 2024 1

I am using the vue-loading without any problem with vuex, see example of an action

freshDocuments(context) {
      let loader = Vue.$loading.show()
      Vue.$http.get('documents/all')
          .then((response) => {
            context.commit('freshDocuments', response.data.data)
          })
          .catch((error) => {
            Vue.$toast.error('Error fetching documents.')
          })
          .finally((res) => {
            loader.hide()
          })
    },

from vue-loading-overlay.

yabasha avatar yabasha commented on May 26, 2024

I can use it inside components but I want to display it with axios requests which are in store actions.

from vue-loading-overlay.

tomisicm avatar tomisicm commented on May 26, 2024

Is there a way to store loader as a reference and then just call show or hide methods on it?

const loader = context.root.$loading.show({
container: formContainer,
canCancel: false
})

const showLoader = () => {
loader.show()
}

const hideLoader = () => {
loader.hide()
}

Or something like this?

const showLoader = () => context.root.$loading.show({})

const hideLoader = () => {
showLoader().hide()
}

How do I achieve something like this? Found a way below, but can this be cleaner?

let loader

const showLoader = () => {
loader = context.root.$loading.show({})
return loader
}

const hideLoader = () => {
loader.hide()
}

@ankurk91

from vue-loading-overlay.

ankurk91 avatar ankurk91 commented on May 26, 2024

This is a general programing problem, i am not here to teach you how to code.

from vue-loading-overlay.

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.