- Type Parameters:
T
- the row type
- All Known Implementing Classes:
AbstractFilteredModelRefresher
,FilteredModel.AbstractRefresher
- Enclosing interface:
- FilteredModel<T>
public static interface FilteredModel.Refresher<T>
Handles refreshing data for a
FilteredModel
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addRefreshFailedListener
(Consumer<Throwable> listener) void
addRefreshListener
(Runnable listener) async()
Sometimes we'd like to be able to refresh one or more models and perform some action on the refreshed data, after the refresh has finished, such as selecting a particular item or such.Value<Supplier<Collection<T>>>
observer()
void
refresh()
Refreshes the items in the associated filtered model.void
refreshThen
(Consumer<Collection<T>> afterRefresh) Refreshes the data in this model.void
removeRefreshFailedListener
(Consumer<Throwable> listener) void
removeRefreshListener
(Runnable listener)
-
Method Details
-
async
State async()Sometimes we'd like to be able to refresh one or more models and perform some action on the refreshed data, after the refresh has finished, such as selecting a particular item or such. This is quite difficult to achieve with asynchronous refresh enabled, so here's a way to temporarily disable asynchronous refresh, for a more predictable behaviour.- Returns:
- the State controlling whether asynchronous refreshing is enabled
- See Also:
-
itemSupplier
Value<Supplier<Collection<T>>> itemSupplier()- Returns:
- a Value controlling the item supplier for this refresher instance
-
refresh
void refresh()Refreshes the items in the associated filtered model. Note that this method only throws exceptions when run synchronously.- Throws:
RuntimeException
- in case of an exception when running synchronously.- See Also:
-
refreshThen
Refreshes the data in this model. Note that this method only throws exceptions when run synchronously. UseaddRefreshFailedListener(Consumer)
to listen for exceptions that happen during asynchronous refresh.- Parameters:
afterRefresh
- called after a successful refresh, may be null- Throws:
RuntimeException
- in case of an exception when running synchronously.- See Also:
-
observer
StateObserver observer()- Returns:
- an observer active while a refresh is in progress
-
addRefreshListener
- Parameters:
listener
- a listener to be notified each time this model has been successfully refreshed- See Also:
-
removeRefreshListener
- Parameters:
listener
- the listener to remove- See Also:
-
addRefreshFailedListener
- Parameters:
listener
- a listener to be notified each time an asynchronous refresh has failed- See Also:
-
removeRefreshFailedListener
- Parameters:
listener
- the listener to remove
-