- Type Parameters:
T- the row type
- All Known Implementing Classes:
FilteredModel.AbstractRefresher
- Enclosing interface:
- FilteredModel<T>
public static interface FilteredModel.Refresher<T>
Handles refreshing data for a
FilteredModel.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddRefreshFailedListener(Consumer<Throwable> listener) voidaddRefreshListener(Runnable listener) is.codion.common.state.Stateasync()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.is.codion.common.value.Value<Supplier<Collection<T>>>is.codion.common.state.StateObserverobserver()voidrefresh()Refreshes the items in the associated filtered model.voidrefreshThen(Consumer<Collection<T>> afterRefresh) Refreshes the data in this model.voidremoveRefreshFailedListener(Consumer<Throwable> listener) voidremoveRefreshListener(Runnable listener)
-
Method Details
-
async
is.codion.common.state.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
is.codion.common.value.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
is.codion.common.state.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
-