pub struct RefreshRegistry { /* private fields */ }Expand description
Global registry for refresh signals that can trigger provider re-execution
The RefreshRegistry manages the reactive update system for providers. It tracks
which reactive contexts are subscribed to which providers, maintains refresh counters,
and manages periodic tasks for both auto-refreshing and stale-checking.
§Thread Safety
All internal state is protected by mutexes to ensure thread-safe access across different contexts and background tasks.
Implementations§
Source§impl RefreshRegistry
impl RefreshRegistry
Sourcepub fn get_refresh_count(&self, key: &str) -> u64
pub fn get_refresh_count(&self, key: &str) -> u64
Get the current refresh count for a provider key
Returns the number of times the provider has been refreshed, or 0 if not found.
Sourcepub fn subscribe_to_refresh(&self, key: &str, reactive_context: ReactiveContext)
pub fn subscribe_to_refresh(&self, key: &str, reactive_context: ReactiveContext)
Subscribe a reactive context to refresh events for a provider key
When the provider is refreshed, the reactive context will be marked as dirty, causing any components using it to re-render.
Sourcepub fn trigger_refresh(&self, key: &str)
pub fn trigger_refresh(&self, key: &str)
Trigger a refresh for a provider key
This increments the refresh counter and marks all subscribed reactive contexts as dirty, causing components to re-render and providers to re-execute.
Sourcepub fn clear_all(&self)
pub fn clear_all(&self)
Clear all cached data and trigger refresh for all providers
This is useful for global cache invalidation scenarios.
Sourcepub fn start_periodic_task<F>(
&self,
key: &str,
task_type: TaskType,
interval: Duration,
task_fn: F,
)
pub fn start_periodic_task<F>( &self, key: &str, task_type: TaskType, interval: Duration, task_fn: F, )
Start a periodic task for automatic provider operations
Creates a background task that will call the provided function at regular intervals. Supports both interval refresh and stale checking operations. If an existing task exists with a longer interval, it will be replaced. Tasks with shorter intervals are preserved to avoid unnecessary re-creation.
§Cross-Platform Implementation
Uses dioxus::spawn to create tasks that work on both web and desktop platforms.
Tasks are automatically cancelled when the component unmounts.
Sourcepub fn start_interval_task<F>(
&self,
key: &str,
interval: Duration,
refresh_fn: F,
)
pub fn start_interval_task<F>( &self, key: &str, interval: Duration, refresh_fn: F, )
Start an interval task for automatic provider refresh
This is a convenience method for starting interval refresh tasks.
Sourcepub fn start_stale_check_task<F>(
&self,
key: &str,
stale_time: Duration,
stale_check_fn: F,
)
pub fn start_stale_check_task<F>( &self, key: &str, stale_time: Duration, stale_check_fn: F, )
Start a stale check task for SWR behavior
This is a convenience method for starting stale checking tasks.
Sourcepub fn stop_periodic_task(&self, key: &str, task_type: TaskType)
pub fn stop_periodic_task(&self, key: &str, task_type: TaskType)
Stop a periodic task
Removes the task from the registry. The actual task will complete its current iteration and then stop.
Sourcepub fn stop_interval_task(&self, key: &str)
pub fn stop_interval_task(&self, key: &str)
Stop an interval task
This is a convenience method for stopping interval refresh tasks.
Sourcepub fn stop_stale_check_task(&self, key: &str)
pub fn stop_stale_check_task(&self, key: &str)
Stop a stale check task
This is a convenience method for stopping stale checking tasks.
Sourcepub fn is_revalidation_in_progress(&self, key: &str) -> bool
pub fn is_revalidation_in_progress(&self, key: &str) -> bool
Check if a revalidation is currently in progress for a provider key
This prevents duplicate revalidations from being started simultaneously.
Sourcepub fn start_revalidation(&self, key: &str) -> bool
pub fn start_revalidation(&self, key: &str) -> bool
Start a revalidation for a provider key
Returns true if the revalidation was started, false if one was already in progress. This prevents duplicate revalidations from running simultaneously.
Sourcepub fn complete_revalidation(&self, key: &str)
pub fn complete_revalidation(&self, key: &str)
Complete a revalidation for a provider key
This should be called when a revalidation finishes, regardless of success or failure.
Sourcepub fn stats(&self) -> RefreshRegistryStats
pub fn stats(&self) -> RefreshRegistryStats
Get statistics about the refresh registry
Sourcepub fn cleanup(&self) -> RefreshCleanupStats
pub fn cleanup(&self) -> RefreshCleanupStats
Clean up unused subscriptions and tasks
Trait Implementations§
Source§impl Clone for RefreshRegistry
impl Clone for RefreshRegistry
Source§fn clone(&self) -> RefreshRegistry
fn clone(&self) -> RefreshRegistry
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read more