flexyford / impagination

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

Filter records #26

Closed flexyford closed 8 years ago

flexyford commented 8 years ago

Fix #25 Filtering records on Resolved Pages is applied whenever a fetch returns.

Previously each page had records, but this has been extended to unfilteredRecords and records (where records are now records which include all records which passed through the filter).

We also introduce a filter function on the dataset, which applies the filter every time a page is resolved!

Fix #27 Introduce actions for refreshing the dataset (aka reapplying filters) and resetting the dataset (unloading all pages and refetch the dataset). refresh(readOffset) will reapply filters on all pages from the given offset (defaultOffset: currentOffset) reset(readOffset) will unload and refetch all pages from the given offset (defaultOffset: 0)

cowboyd commented 8 years ago

I'm still uncomfortable with the intertwining of setReadOffset, refilter and reload actions, and the parameterization of setReadOffset.

I'm worried that we're using the wrong abstraction in order to avoid duplication. In my mind, the refiltering should do nothing except walk the resolved pages, and replace them with a filtered version of the pages. Same thing with reload.

If we do find out which operations are common between them, then perhaps we can introduce a new abstraction instead of try to piggy back on the existing one.