Interface FilteredModel.Refresher<T>

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 Details

    • asyncRefresh

      State asyncRefresh()
      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 should be enabled, true by default
      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

      void refreshThen(Consumer<Collection<T>> afterRefresh)
      Refreshes the data in this model. Note that this method only throws exceptions when run synchronously. Use addRefreshFailedListener(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

      void addRefreshListener(Runnable listener)
      Parameters:
      listener - a listener to be notified each time this model has been successfully refreshed
      See Also:
    • removeRefreshListener

      void removeRefreshListener(Runnable listener)
      Parameters:
      listener - the listener to remove
      See Also:
    • addRefreshFailedListener

      void addRefreshFailedListener(Consumer<Throwable> listener)
      Parameters:
      listener - a listener to be notified each time an asynchronous refresh has failed
      See Also:
    • removeRefreshFailedListener

      void removeRefreshFailedListener(Consumer<Throwable> listener)
      Parameters:
      listener - the listener to remove