dhilt / vscroll

A JavaScript Virtual Scroll Engine
https://dhilt.github.io/vscroll/
MIT License
39 stars 2 forks source link

Workflow is broken in background tab #16

Closed fclmman closed 2 years ago

fclmman commented 3 years ago

Hi! I am using ngx-ui-scroll, and got an issue when running app in background tab. In our app we need to update data and append new rows, but because of browser throttling and asynchronousity in vscroll workflow, in background tab it seems to be broken and new nodes are not appended to dom.

dhilt commented 3 years ago

@fclmman Hi! May I ask you to look at https://stackblitz.com/edit/ngx-ui-scroll-append-async and make necessary updates to reproduce the issue? I implemented setInterval-append process, which works fine, as I can see, wether you are on the tab or not.

The main point of any async updates is to provide synchronous chaining on the Scroller's end:

async doAppend(item: MyItemData) {
    await this.datasource.adapter.relax(); // wait for all the internal processes on the Scroller's end are done
    this.appendToDatasource(item); // make sure that we updated the external data source on the App side
    await this.datasource.adapter.append({ // push updates to the Scroller
      items: [item],
      eof: true
    });
    this.datasource.adapter.clip(); // cut off extra (out-of-view) items if needed
}
fclmman commented 3 years ago

@dhilt hi, i'll check your solution in closest time, but looks quite similar to what we have implemented already. Can there be any additional issues with OnPush strategy?

dhilt commented 3 years ago

@fclmman Who knows... We'll investigate the problem and maybe it will be the App logic issue, maybe it will be something on the Scroller's end. Async updates in a passive tab must work anyway, but to know what exactly is happening and how to fix it the repro is needed.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed within seven days if no further activity occurs. If it needs to remain open, add the "permanent" label.

stale[bot] commented 2 years ago

This issue has been automatically closed because it was stale.