Module is.codion.common.model
Package is.codion.common.model.filter
Interface FilterModel.Refresher<T>
- Type Parameters:
T- the type of items produced by thisFilterModel.Refresher
- Enclosing interface:
FilterModel<T>
public static interface FilterModel.Refresher<T>
Handles refreshing data for a
FilterModel.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionactive()Changes to this state are triggered on the UI thread when refreshed asynchronously, otherwise on the calling thread (seerefresh(Consumer)).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.static <T> FilterModel.Refresher.Builder<T> builder()voidrefresh(@Nullable Consumer<Collection<T>> onResult) Refreshes the data.result()This event is triggered on the UI thread when refreshed asynchronously, otherwise on the calling thread (seerefresh(Consumer)).
-
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
Statecontrolling whether asynchronous refreshing is enabled - See Also:
-
active
ObservableState active()Changes to this state are triggered on the UI thread when refreshed asynchronously, otherwise on the calling thread (see
refresh(Consumer)).- Returns:
- an observable indicating that a refresh is in progress
-
result
Observer<Collection<T>> result()This event is triggered on the UI thread when refreshed asynchronously, otherwise on the calling thread (see
refresh(Consumer)).- Returns:
- an observer notified with the result after a successful refresh
-
refresh
Refreshes the data. Async refresh is performed when it is enabled (
async()) and this method is called where a dispatch context is bound, the UI thread on UI platforms.Note that a refresh superseded by a subsequent refresh invokes no callbacks.
- Parameters:
onResult- called with the result after a successful refresh, may be null (on the UI thread when refreshed asynchronously)- See Also:
-
builder
- Type Parameters:
T- the item type- Returns:
- a new
FilterModel.Refresher.Builderinstance
-