Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having more than 1500 items some function calls to fill the list are lost #293

Open
nelsonlarocca opened this issue Sep 1, 2020 · 0 comments

Comments

@nelsonlarocca
Copy link

1- if you trigger the load frequently it drops an error

2- after several times invoking the function to add items to the list to be displayed, the function starts auto-triggering itself but info is never displayed. Try it with 1500 items and you'll got it

3- if you load some thousands some times the function that fills the list is not invoked so also they are never displayed

Heres one of the codes:

<template>
  <v-container v-bind="{ [`grid-list-${size}`]: true }" fluid>
    <v-layout align-start justify-start row wrap mx-auto>
      <v-flex v-for="(item, $index) in bizList" :key="$index">
        <MyCard
          :id="item.id"
          :name="item.name"
          :index="$index"
        />
      </v-flex>
    </v-layout>
    <infinite-loading
      ref="infiniteLoading"
      spinner="spiral"
      @infinite="infiniteHandler"
    >
      <span slot="no-more">--- End of Listing ---</span>
      <span slot="no-results">No Records Found</span>
    </infinite-loading>
  </v-container>
</template>

<script>
import { mapGetters } from 'vuex'
import MyCard from '@/components/biz/MyCard'

export default {
  middleware: 'auth',
  layout: 'dashboard',
  components: {
    MyCard,
  },
  data() {
    return {
      page: 0,
      list: [],
      message: '',
      size: 'md',
      currentCard: 0,
      itemsPerPage: 10,
    }
  },
  computed: {
    ...mapGetters({
...
    }),
  },

  methods: {
    infiniteHandler($state) {
      const items = this.bizList.slice(
        this.page * this.itemsPerPage,
        (this.page + 1) * this.itemsPerPage
      )

      console.log('page -> ', this.page, 'items -> ', items)

      setTimeout(() => {
        if (items.length) {
          console.log('entering if items ', this.page)
          this.page++
          this.list.push(...items)
          $state.loaded()
        } else {
          $state.complete()
        }
      }, 1000)
    },
  },
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant