Interface FilterModel.Refresher<T>

Type Parameters:
T - the type of items produced by this FilterModel.Refresher
Enclosing interface:
FilterModel<T>

public static interface FilterModel.Refresher<T>
Handles refreshing data for a FilterModel.
  • 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:
    • 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

      void refresh(@Nullable Consumer<Collection<T>> onResult)

      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

      static <T> FilterModel.Refresher.Builder<T> builder()
      Type Parameters:
      T - the item type
      Returns:
      a new FilterModel.Refresher.Builder instance