RefreshRegistry

Struct RefreshRegistry 

Source
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

Source

pub fn new() -> Self

Create a new refresh registry

Source

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.

Source

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.

Source

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.

Source

pub fn clear_all(&self)

Clear all cached data and trigger refresh for all providers

This is useful for global cache invalidation scenarios.

Source

pub fn start_periodic_task<F>( &self, key: &str, task_type: TaskType, interval: Duration, task_fn: F, )
where F: Fn() + Send + 'static,

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 can be cancelled explicitly using stop_* methods, which set a cancellation flag.

Source

pub fn start_interval_task<F>( &self, key: &str, interval: Duration, refresh_fn: F, )
where F: Fn() + Send + 'static,

Start an interval task for automatic provider refresh

This is a convenience method for starting interval refresh tasks.

Source

pub fn start_stale_check_task<F>( &self, key: &str, stale_time: Duration, stale_check_fn: F, )
where F: Fn() + Send + 'static,

Start a stale check task for SWR behavior

This is a convenience method for starting stale checking tasks.

Source

pub fn stop_periodic_task(&self, key: &str, task_type: TaskType)

Stop a periodic task

Signals the task to stop by setting its cancellation flag and removes it from the registry. The task will stop after its current iteration completes.

Source

pub fn stop_interval_task(&self, key: &str)

Stop an interval task

This is a convenience method for stopping interval refresh tasks.

Source

pub fn stop_stale_check_task(&self, key: &str)

Stop a stale check task

This is a convenience method for stopping stale checking tasks.

Source

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.

Source

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.

Source

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.

Source

pub fn stats(&self) -> RefreshRegistryStats

Get statistics about the refresh registry

Source

pub fn cleanup(&self) -> RefreshCleanupStats

Clean up unused subscriptions and tasks

Trait Implementations§

Source§

impl Clone for RefreshRegistry

Source§

fn clone(&self) -> RefreshRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for RefreshRegistry

Source§

fn default() -> RefreshRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more