Scroll Lazy Load with JS Promise

First, listen the scroll event from client

What different means for _.throttle & _.debounce?
The debounce technique allow us to "group" multiple sequential calls in a single one.
It means updateViewport function will be called after the caller stops scrolling after a specified period.

Throttle means updateViewport function will be called at most once per specified scrolling period..

Second, check if there is any unseeing data has been scrolled to display on the view port of device.  

If yes, then call get data api to merge it into current data structure then re-render it.


Finally, resolve this promise then do it until all data have been loaded and displayed.


留言