Class DataFetchObserver
- All Implemented Interfaces:
Serializable
service event bus.
For internal use by data communicators. Each method wraps the query it is
given, so the started/failed/ended sequence is defined in one place rather
than repeated at every call site. The ended event is fired in reverse
registration order, so listeners nest around the started one.
The caller supplies the UI rather than this class looking one up, because
VaadinService.getCurrent() is unavailable on the thread that matters:
DataCommunicator.enablePushUpdates(java.util.concurrent.Executor)
runs fetches on the supplied executor without propagating
CurrentInstance. When the component is not
attached to a live UI the query simply runs unreported.
- Since:
- 25.3
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic intcount(com.vaadin.flow.component.UI ui, com.vaadin.flow.component.Component component, boolean filtered, IntSupplier query) Runs a count query, reporting it on the service event bus.static intfetch(com.vaadin.flow.component.UI ui, com.vaadin.flow.component.Component component, com.vaadin.flow.internal.Range range, boolean filtered, IntSupplier query) Runs a fetch query, reporting it on the service event bus.
-
Method Details
-
count
public static int count(com.vaadin.flow.component.UI ui, com.vaadin.flow.component.Component component, boolean filtered, IntSupplier query) Runs a count query, reporting it on the service event bus.- Parameters:
ui- the UI the counting component belongs to, ornullif it is not attachedcomponent- the component whose data is being counted, ornullif it could not be resolvedfiltered- whether the query carries a filterquery- the count query to run- Returns:
- whatever the query returned
-
fetch
public static int fetch(com.vaadin.flow.component.UI ui, com.vaadin.flow.component.Component component, com.vaadin.flow.internal.Range range, boolean filtered, IntSupplier query) Runs a fetch query, reporting it on the service event bus.The query must consume the items it loads and return how many there were, so that the reported duration covers the backend round-trip even for a data provider that returns a lazily evaluated
Stream.- Parameters:
ui- the UI the fetching component belongs to, ornullif it is not attachedcomponent- the component whose data is being fetched, ornullif it could not be resolvedrange- the range of items requestedfiltered- whether the query carries a filterquery- the fetch query to run, returning the number of items loaded- Returns:
- whatever the query returned
-