flexyford / impagination

A lazy data layer for your paged records
102 stars 7 forks source link

Handle unfetch() of records #6

Closed cowboyd closed 8 years ago

cowboyd commented 8 years ago

Add the ability to pass in an unfetch option that will be invoked whenever a page is unloaded. This allows you to do thing like perform any cleanup associated with those records such as unload the record from a data store:

let dataset = new Dataset({
  fetch: function(pageOffset, pageSize) {
    return this.store.find('color', {page: pageOffset, perPage: pageSize});
  },
  unfetch: function(records) {
    records.forEach(function(record) {
      record.unload();
    });
  }
});
flexyford commented 8 years ago

Worked on this for #12 but implemented

unfetch: function(pageOffset) {
    ...
  }

I'll edit the code to reflect your implementation below

unfetch: function(records, pageOffset) {
    ...
  }
flexyford commented 8 years ago

Fixed on #12