I am working on an application being built with Bacon.js, and using React for rendering (though that doesn't seem to be germane to the question. I am building a page that is an infinitely scrolling list of data. You can filter or sort the results, add or remove columns. I have this basically working, but the implementation is leaving a bit to be desired.
I have a query stream
const query = combineTemplate({
checksum,
fields,
filters,
sort,
page
})
I listen for changes on this stream and fire off new queries which update my items:
const searches
const items = update([],
[query.changes().map(({checksum}) => checksum).skipDuplicates()], () => [],
[searches], mergeResults
)
The checksum in there is generated off of the fields, filters and sort, And basically tells me when I need to completely clear my current result set. One other note is that the infinitely scrolling list is setup to show the entire length of the result set even if not all pages are loaded yet, so the result set length needs to be equal to the total length, taking on additional pages isn't sufficient.
As I noted, I have this working, but it seems really fragile, and messy. Was wondering if there was any techniques people had for managing this type of situation, most of the posts I have seen seem to assume you will always be getting your entire data set back.