Hi Fanis Despoudis,
Thanks for the feedback and suggestions. This blog post was not about exhaustive/optimized implementation of a library but concepts which involves in implementing an infinite scroll.
For infinite scroll implementation these are the requirements which I wanted to cover,
- Events when scrolled down which needs to keep track of previously scrolled position
- Trigger the event only when passed certain percentage of the container
- Wait until the previous http/async call is done and only then emit the event of scroll (This would avoid the consumer implementing this conditional)
- Debounce the events so scroll events are not emitted on each single scroll.
These are the above concepts that I wanted to showcase.
The reference of ion-infinite-scroll, this is the source code and it is a different implementation : https://github.com/ionic-team/ionic/blob/master/src/components/infinite-scroll/infinite-scroll.ts.
ion-infinite-scroll is not a simple approach as well, the comparison you had made was about the directive API exposed vs Library implementation if I am correct.
Regarding, the line you mentioned
.subscribe(() => {})
was to showcase you can perform post processing if required, I could have just done the below.
.subscribe()
I will make that change to the post as it wasn’t conveying the intended thought.
Again, thank you so much for taking time to read and post feed, really appreciate it.
