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 can i emit events from a plugin.

    Help
    2
    2
    421
    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.
    • M
      Mardugh last edited by

      I am essentially trying to write a plugin with async-functionality i will be needing throughout a lot of my vue components.
      And so far it mostly works, but the one thing i cannot seem to figure out is how to emit events from said plugin and act upon these events in my vue components.

      What i have so far essentially boils down to the following:

      import axios from 'axios'
      
      function update () {
          axios.get(`...magic-url...`)
              .then(response => {
                  this.$emit('update')
              })
              .catch(e => {
                  console.log(e)
              })
      }
      
      var api = {
          update,
      }
      
      export default ({ Vue }) => {
          Vue.prototype.$foobar = api
      }
      

      The basic problem is the this.$emit('update') inside the axios-call. I assume this is probably because my ‘API’ is not actually aware of anything Vue related but i can’t seem to figure how to go about making this work.

      I would appreciate any pointers, and perhaps an example of how to act upon these events in vue-components once the $emit issue is actually taken care off.

      1 Reply Last reply Reply Quote 0
      • C
        chand last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • First post
          Last post