You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When using data providers I want to be able just to supply a Stream and let the provider filter/sort/skip/limit with Stream methods #2487
When using Grid, ComboBox or any other component using data providers, I want to be able just to supply a Stream and let the provider filter/sort/skip/limit with Stream methods, so that I can use my own Stream implementation without the need to bother with Query or SortOrders.
Components such as Grid/ComboBox should then accept standard Java 8 Predicate and Comparator to filter and sort, and means to combine them so that I can also use custom implementation of these to optimize backend fetching.
I think streams are a great feature which already provides all the needed logic to components which has items and it should be the default backing interface for data providers, e.g. DataProvider.ofCollection should get collection.stream() and not the other way around (i.e. collecting DataProvider.fromStream to a list).
changed the title [-]When using Grid I want to be able just to supply a Stream and let Grid filter/sort/skip/limit with Stream methods[/-][+]When using data providers I want to be able just to supply a Stream and let the provider filter/sort/skip/limit with Stream methods[/+]on Sep 24, 2017
Since a Stream can only be traversed once, you'd really have to provide a Supplier<Stream<T>> instead so that new items can be fetched e.g. when filtering changes.
Since the entire DataProvider API is shared with Framework 8, the changes should maybe be done there first and then forward-ported to Flow?
Yes, you'd have to provide a stream supplier! Then it will be really easy for the developer to use data providers, using e.g. Speedment streams in production and mocking them with standard Java streams in testing.
Simple use case, using the Speedment documention example, where films can provide a backend-aware stream:
DataProvider<Film, Predicate<Film>> filmProvider =
DataProvider.fromStream(films::stream);
TextFieldtitleFilter = newTextField("Filter by title");
titleFilter.addChangeListener(event ->
// using standard PredicatefilmProvider.setFilter(film -> film.getTitle().startsWith(event.getValue())));
// using optimized PredicatefilmProvider.setFilter(Film.TITLE.startsWith(event.getValue())));
Grid<Film> filmGrid = newGrid<>();
grid.setDataProvider(filmProvider);
grid.addColumn("Title", Film::getTitle);
grid.addColumn("Length", Film::getLength)
// using standard Comparator
.sortingWith(Comparator.comparing(Film::getLength));
// using optimized Comparator
.sortingWith(Film.LENGTH::comparator);
It would be great to have this on FW8 and Stream both, if the API is shared!
One small nit about your example: You have to use withConfigurableFilter to get a DataProvider instance with a setFilter method. The basic DataProvider interface only accepts filters directly through the query, i.e. from a ComboBox.
Closing: lazy data binding with setItems(query -> ...) already lets the fetch callback return a Stream built from the query's offset, limit, sort orders and filter. Accepting a plain Stream supplier with Predicate/Comparator filtering is not planned.
Activity
[-]When using Grid I want to be able just to supply a Stream and let Grid filter/sort/skip/limit with Stream methods[/-][+]When using data providers I want to be able just to supply a Stream and let the provider filter/sort/skip/limit with Stream methods[/+]Legioth commentedon Sep 24, 2017
Since a
Streamcan only be traversed once, you'd really have to provide aSupplier<Stream<T>>instead so that new items can be fetched e.g. when filtering changes.Since the entire
DataProviderAPI is shared with Framework 8, the changes should maybe be done there first and then forward-ported to Flow?heruan commentedon Sep 24, 2017
Yes, you'd have to provide a stream supplier! Then it will be really easy for the developer to use data providers, using e.g. Speedment streams in production and mocking them with standard Java streams in testing.
Simple use case, using the Speedment documention example, where
filmscan provide a backend-aware stream:It would be great to have this on FW8 and Stream both, if the API is shared!
Legioth commentedon Sep 24, 2017
One small nit about your example: You have to use
withConfigurableFilterto get aDataProviderinstance with asetFiltermethod. The basicDataProviderinterface only accepts filters directly through the query, i.e. from aComboBox.totally-not-ai commentedon Dec 5, 2026
Closing: lazy data binding with
setItems(query -> ...)already lets the fetch callback return aStreambuilt from the query's offset, limit, sort orders and filter. Accepting a plainStreamsupplier withPredicate/Comparatorfiltering is not planned.