Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to pass all the data at a time (as an alternative to Datasource.get) #90

Open
philly-vanilly opened this issue Apr 9, 2019 · 4 comments
Labels
enhancement permanent ignore stale bot

Comments

@philly-vanilly
Copy link

philly-vanilly commented Apr 9, 2019

If I understand correctly, there is no way to pass a whole array of items (handled in the redux store or some other external model) to the adapter/datasource-get and make it accept all of them. Instead you have to manually synchronize all the changes that happen at network-layer with subscibe/update methods. For enterprise applications that have layered architecture with separation of business and UI, this means a lot of boilerplate code that can and will result in bugs.

It would be nice if you could just pass an array or observable of an array to the ngx-ui-scroll directive (same way as angular material CDK or Ionic) and make it handle the rest.

@dhilt
Copy link
Owner

dhilt commented Apr 9, 2019

@philly-vanilly Thanks for the issue! Looking through Material CDK Virtual scrolling documentation, I would say that current ngx-ui-scroll approach correlates with "Virtual scroll with a custom data source" ("Specifying data") Material approach. They also suggest to implement MyDataSource and provide paging data flow manually (example).

I'm not going to explain why manual datasource approach is important or could be useful, but I would agree that it is a good idea to have an additional API allowing to pass all the data array at a time. Also, I believe Redux isn't involved here. So I'm going to change the issue title and add "enhancement" label.

@dhilt dhilt changed the title Redux support (external model) Allow to pass all the data at a time (as an alternative to Datasource.get) Apr 9, 2019
@stale
Copy link

stale bot commented Jan 15, 2020

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 stale bot added the stale label Jan 15, 2020
@dhilt dhilt added permanent ignore stale bot and removed stale labels Jan 15, 2020
@HadiAyoub
Copy link

Hi @dhilt ,
Priority wise, is this something likely to be brought in soon? are there any workarounds?

Thanks for keeping up one of most well documented and maintained repos btw. Very appreciated

@dhilt
Copy link
Owner

dhilt commented Jan 19, 2021

@HadiAyoub I'm keeping this issue in mind, though there are not so many requests on it. Right now all my time is being spent on vscroll finalization, it will be an external framework-free core for ngx-ui-scroll, and this enhancement will go there after v1 is released.

While there is no this feature implemented, you may use the following approach:

datasource = new Datasource({
  get: (start, count, success) => {
    const end = Math.min(start + count - 1, this.data.length - 1);
    success(start <= end ? this.data.slice(start, end + 1) : []);
  }
})

Here this.data is your dataset fixed on the Component's level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement permanent ignore stale bot
Projects
None yet
Development

No branches or pull requests

3 participants