polymerfire icon indicating copy to clipboard operation
polymerfire copied to clipboard

Create firebase-list component

Open phidias51 opened this issue 8 years ago • 4 comments

A common use-case for dealing with the query results is to page through the list of items. In iron-list, they have the concept of a scroll-threshold. As you scroll down to the bottom of the list, it fetches the next "page" of data.

It would be a time saver, if this was wrapped up as a component for us. Something like this:

<firebase-list path="/users" ... page-size="50"></firebase-list>

Or if you wanted more control over it:

<firebase-list page-size="50" no-value-message="No Users Were Found">
  <firebase-query path="/users" ..></firebase-query>
</firebase-list>

In the latter example, if the query didn't return any values, then the "No Users Were Found" message would appear in the list.

phidias51 avatar Apr 07 '17 18:04 phidias51

Ah yes, I do also have that kind of use-case. The problem with the current implementation of firebase-query is that any change in the attributes renders the array data to start from an empty element and then populates it again. What I usually do is to put it in a temporary array, and then use that array as the source of the iron-list. I also do not delete the array if and when the changes are only the limit and startAt/endAt. But the problem with this is that any changes from the child elements will not reflect automatically to the temporary array because it is disconnected to the firebase-query innards (which uses app-storage).

There can be a way though, but my mind is getting fried as of the moment thinking of a technical solution for this :P

tjmonsi avatar Apr 11 '17 17:04 tjmonsi

You could query only for a certain number of results and your starting point could be the index of the last result + 1. If your value is null then start with the 0 index. Then, fire an event when you reach the bottom of the scroll until there are not more results to load.

justweb1 avatar May 20 '17 22:05 justweb1

@tjmonsi the app-indexeddb-mirror-client element should take care of caching the results. I say "should" because there seems to be an issue with it at the moment.

phidias51 avatar Jun 08 '17 15:06 phidias51

I found this: https://github.com/deltaepsilon/firebase-paginator which has some interesting ideas in it.

phidias51 avatar Jun 08 '17 22:06 phidias51