hilongjw / vue-recyclerview

Mastering Large Lists with the vue-recyclerview
https://hilongjw.github.io/vue-recyclerview/
MIT License
1.45k stars 121 forks source link

Example confussing #5

Closed hazzo closed 7 years ago

hazzo commented 7 years ago

Hi I having several issue to reproduce the example with my own data. I don't get why those al fetch functions are needed (query, getItem(), etc). Don't understand de purpose of limit and skip (suppose they are used inside component but don't know what they do).

Tombstone is needed obligatory? Should be an option.

Please if you could give an example by declaring all the functions as methods (if possible, declared out of vue makes "this" unusable) and using data in the component or vuex.

Thanks and great component!

hilongjw commented 7 years ago

@hazzo Hi, The list data are organized by the RecyclerView, so the fetch method is required to provide data directly to the RecyclerView. And The Tombstone can be optional, but I suggest providing a custom Tombstone because the tombstone height needs to be similar to Item, so that the Tombstone and Item switching will be smoother.

// limit means how much data is needed
// skip means how much data already exists
function fetch (limit, skip) {
  return axios({
    url: 'api/url/',
    params: {
      search: 'some keyword',
      skip: skip,
      limit: limit
    }
  }).then(res => {
    return {
       count: res.data.total,  // total count
       list: res.data.results
    }
  })
}
hazzo commented 7 years ago

Fantastic​, thanks! I was going to close this issue because I manage to understand it and reproduce it with my own data. Works great! Congrats!