kelp icon indicating copy to clipboard operation
kelp copied to clipboard

[feature] Pagination widget with lazy loading

Open DSeeLP opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. Currently to use the pagination with a database you need to load all entries and map them to a kelp item.

Describe the solution you'd like A lazy Pagination class which has a type argument and needs an supplier and two functions. The supplier returns the max page and the first function takes an int as the page and returns an array or list of the type. The second function takes an object of the type and returns a kelp item.

DSeeLP avatar Apr 03 '21 11:04 DSeeLP

So you mean something like this?

class LazyPagination<T> {

  ...

  public int getMaxPage() { 
    return supplier.get(); 
  }

  public Collection<T> getWidgetsFor(int page) { ... }

  public KelpItem getItem(T type) { ... }

}

The idea of a lazy loading pagination is really good, you are right that loading all pages for a simple update is overkill. But what does the class type stand for in this case? Is it a widget type? Because then you couldn't render different database entries as different widget types anymore.

PXAV avatar Apr 04 '21 10:04 PXAV

Yes i meant something like this. In my example the class type stands for the object obtained from the database.

DSeeLP avatar Apr 05 '21 16:04 DSeeLP