Skip to main content

fetch_query

Function fetch_query 

Source
pub fn fetch_query<T, E, C, F, Fut>(
    entity: &Entity<QueryResource<T, E>>,
    fetcher: F,
    cx: &mut Context<'_, C>,
)
where T: Clone + Send + Sync + 'static, E: Clone + Send + Sync + Debug + 'static, C: 'static, F: Fn() -> Fut + Send + 'static, Fut: Future<Output = Result<T, E>> + Send + 'static,
Available on crate feature hook only.
Expand description

Initiate a fetch on an existing query entity.

Call this when you want to refetch (e.g., on button click or timer). Respects the resource’s retry policy on failure.

Calls begin_request to obtain a fresh RequestId and transition the resource to Loading before spawning the fetch task.

Audit fix #3: If begin_request returns None (cache hit or ignored), no async fetch task is spawned, avoiding wasted resources.