pub struct UseStorageOptions<T, E, D, F = NoFilter>{ /* private fields */ }Expand description
Options for use with crate::use_local_storage_with_options, crate::use_session_storage_with_options and use_storage_with_options.
Options for crate::use_storage_with_options.
The filter is a type parameter so that the debounce and throttle code is only compiled into your app if you use it.
Implementations§
Source§impl<T, E, D, F> UseStorageOptions<T, E, D, F>
impl<T, E, D, F> UseStorageOptions<T, E, D, F>
Sourcepub fn on_error(
self,
on_error: impl Fn(UseStorageError<E, D>) + Send + Sync + 'static,
) -> Self
pub fn on_error( self, on_error: impl Fn(UseStorageError<E, D>) + Send + Sync + 'static, ) -> Self
Optional callback whenever an error occurs.
Sourcepub fn listen_to_storage_changes(self, listen_to_storage_changes: bool) -> Self
pub fn listen_to_storage_changes(self, listen_to_storage_changes: bool) -> Self
Whether to continuously listen to changes from browser storage. Defaults to true.
Sourcepub fn initial_value(self, initial: impl Into<MaybeRwSignal<T>>) -> Self
pub fn initial_value(self, initial: impl Into<MaybeRwSignal<T>>) -> Self
Initial value to use when the storage key is not set. Note that this value is read once on creation of the storage hook and not updated again. Accepts a signal and defaults to T::default().
Sourcepub fn filter<NewF>(self, filter: NewF) -> UseStorageOptions<T, E, D, NewF>
pub fn filter<NewF>(self, filter: NewF) -> UseStorageOptions<T, E, D, NewF>
Debounce or throttle the writing to storage whenever the value changes with a
FilterOptions. Defaults to no filter.
Sourcepub fn delay_during_hydration(self, delay_during_hydration: bool) -> Self
pub fn delay_during_hydration(self, delay_during_hydration: bool) -> Self
Delays the reading of the value from storage by one animation frame during hydration.
This ensures that during hydration the value is the initial value just like it is on the server
which helps prevent hydration errors. Defaults to false.
Trait Implementations§
Auto Trait Implementations§
impl<T, E, D, F = NoFilter> !RefUnwindSafe for UseStorageOptions<T, E, D, F>
impl<T, E, D, F = NoFilter> !UnwindSafe for UseStorageOptions<T, E, D, F>
impl<T, E, D, F> Freeze for UseStorageOptions<T, E, D, F>where
Arc<dyn Fn(UseStorageError<E, D>) + Send + Sync>: Freeze,
MaybeRwSignal<T>: Freeze,
F: Freeze,
impl<T, E, D, F> Send for UseStorageOptions<T, E, D, F>
impl<T, E, D, F> Sync for UseStorageOptions<T, E, D, F>
impl<T, E, D, F> Unpin for UseStorageOptions<T, E, D, F>
impl<T, E, D, F> UnsafeUnpin for UseStorageOptions<T, E, D, F>where
Arc<dyn Fn(UseStorageError<E, D>) + Send + Sync>: UnsafeUnpin,
MaybeRwSignal<T>: UnsafeUnpin,
F: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more