Interface FilterModel.Refresher<T>

Type Parameters:
T - the type of items produced by this FilterModel.Refresher
All Known Implementing Classes:
AbstractRefreshWorker, FilterModel.AbstractRefresher
Enclosing interface:
FilterModel<T>

public static interface FilterModel.Refresher<T>
Handles refreshing data for a FilterModel.
  • Method Summary

    Modifier and Type
    Method
    Description
    Changes to this state are always triggered on the UI thread.
    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 event is always triggered on the UI thread.
    void
    Refreshes the data.
    This event is always triggered on the UI thread.
  • 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 always triggered on the UI thread.

      Returns:
      an observable indicating that a refresh is in progress
    • result

      Observer<Collection<T>> result()

      This event is always triggered on the UI thread.

      Returns:
      an observer notified with the result after a successful refresh
    • exception

      Observer<Exception> exception()

      This event is always triggered on the UI thread.

      Returns:
      an observer notified with the exception when an asynchronous refresh has failed
    • refresh

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

      Refreshes the data. Note that this method only throws exceptions when run synchronously.

      Use exception() to listen for exceptions that happen during asynchronous refresh.

      Async refresh is performed when it is enabled (async()) and this method is called on the UI thread.

      Parameters:
      onResult - called with the result after a successful refresh, may be null
      Throws:
      RuntimeException - in case of an exception when running synchronously.
      See Also: