Best way to reuse custom pagination variables/methods

#1

Hey guys, using Blaze I currently manage my tables’ pagination by setting reactive vars with variables limit, skip etc and have them autorun, then I write methods that update these variables to in turn update the publication. It works really nicely but was wondering if there are any good strategies to be able to reuse this across multiple templates?

I’m also dabbling with viewmodel which allows for mixins but not sure that would cover this. So far I’ve extracted various functions to a pagination import/export which works well (as long as I pass in the template instance) but then I still have to wire up all the click handlers anyway (but at least the pagination complexity is extracted):

showNext() {
    return pagination.showNext(this)
  },
  
  goNext() {
    return pagination.next(this)
  },

  showPrevious() {
    return pagination.showPrevious(this)
  },

  goPrevious() {
    return pagination.previous(this)
  },