use_load_on_demand

Function use_load_on_demand 

Source
pub fn use_load_on_demand<T, L, Q, E, M>(
    range_to_load: impl Into<Signal<Range<usize>>>,
    range_to_display: impl Into<Signal<Range<usize>>>,
    loader: L,
    query: impl Into<Signal<Q>>,
) -> UseLoadOnDemandResult<T, E>
where T: Send + Sync + 'static, L: InternalLoader<M, Item = T, Query = Q, Error = E> + 'static, Q: Send + Sync + 'static, E: Send + Sync + Debug + 'static,
Expand description

Load items on demand and cache them.

Underlying functionality of [use_pagination] and [use_virtualization]. You most probably don’t want to use this directly but either [use_pagination] or [use_virtualization].

§Params

  • load_range: A signal of the range of items to load. This has to include the display_range. Control the range of items to load and cache.
  • display_range: A signal of the range of items to display. This will be used for the returned ItemWindow.
  • loader: The loader to use for loading items.
  • query: A signal of the query to use for loading items.

§Returns

A tuple containing:

  • Signal<Result<Option<usize>, E>>: A signal of the total number of items. This will be either:
    • Ok(Some(n)): The total number of items.
    • Ok(None): The total number of items is unknown.
    • Err(e): An error occurred while loading the total number of items.
  • ItemWindow<T>: A window of items that can be used to render a list/table of items.