Infinite Scroll Callback in Vuex



  • I am not able to call the ‘callback (done)’ in my vuex action.

    The action is mapped this way to the component

    <q-infinite-scroll :handler=“loadMore”>
    </q-infinite-scroll>

    loadMore: function(index, done) {
    
       this.$store.dispatch('myBackendRequest').then(response => {
          done() // This does not work. Keeps calling my request continuously.
       })
      .catch(function (error) {
    
      })
    
    }
    

    Vuex Store:

    actions: {
    
     myBackendRequest({commit}, index, done) {
    
         console.log(index); //works well and counts for each request made
         console.log(done); //is always undefined 
    
       }
    }
    

    How do I call the done() callback, once I get the response back from the server?



  • I don’t use Vuex, but I think I get your problem.
    The done() function won’t prevent Inifinite Scroll from performing another request when the scroll it’s at the end of its run.
    That because an Infinite Scroll do not forecast an end for the data loaded.
    I found a solution using stopScroll() function when I have no more data to fetch from the server.


Log in to reply
 

Looks like your connection to Quasar Framework was lost, please wait while we try to reconnect.