angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
http://angular-ui.github.io/ui-scroll/demo/
MIT License
327 stars 107 forks source link

No way to Implement continuous polling for data rows #200

Closed ghost closed 6 years ago

ghost commented 6 years ago

I am trying to implement ui-scroll in a chat app where server might return empty array after all messages on chat log is served. Need a mechanism to allow polling continuously for new data

dhilt commented 6 years ago

@icernn Empty result leads to setting eof value to true (link). Since the end-of-file is reached, scroll process can't continue. Even if the ui-scroll would allow to reset eof flag programmatically, you still would be at the edge of the viewport and would not able to trigger new data fetching via scrolling. I understand your scenario and would suggest to use Adapter.append/prepend/applyUpdates approach. For example:

  1. Chat log is fully retrieved, bof is reached, scroll process stops.
  2. At some point Client may learn that Server has new records.
  3. Client gets new records in some way (not via ui-scroll).
  4. Using ui-scroll Adapter, Client adds new records to the viewport.

If your datasource has dynamic nature and data can being changed on-flight, the ui-scroll Adapter has to be used to synchronize the viewport and the remote. You may try this demo, it shows basic Adapter features usage.

icernn03 commented 6 years ago

yeah I understand. Was trying to implement it ui-scroll way but failed since data get func is not executed once eof is reached. Im going to try Adapter append/prepend and do update polling outside ui-scroll. Thanks

dhilt commented 6 years ago

You are welcome!