pub struct LocalResource<T> { /* private fields */ }Expand description
A resource that only loads its data locally on the client.
Implementations§
Source§impl<T> LocalResource<T>
impl<T> LocalResource<T>
Source§impl<T, E> LocalResource<Result<T, E>>where
T: 'static,
E: Clone + 'static,
impl<T, E> LocalResource<Result<T, E>>where
T: 'static,
E: Clone + 'static,
Sourcepub fn and_then<U>(&self, f: impl FnOnce(&T) -> U) -> Option<Result<U, E>>
pub fn and_then<U>(&self, f: impl FnOnce(&T) -> U) -> Option<Result<U, E>>
Applies the given function when a resource that returns Result<T, E>
has resolved and loaded an Ok(_), rather than requiring nested .map()
calls over the Option<Result<_, _>> returned by the resource.
This is useful when used with features like server functions, in conjunction
with <ErrorBoundary/> and <Suspense/>, when these other components are
left to handle the None and Err(_) states.
Methods from Deref<Target = AsyncDerived<T>>§
Sourcepub fn ready(&self) -> AsyncDerivedReadyFuture
pub fn ready(&self) -> AsyncDerivedReadyFuture
Returns a Future that is ready when this resource has next finished loading.
Sourcepub fn by_ref(&self) -> AsyncDerivedRefFuture<T>
pub fn by_ref(&self) -> AsyncDerivedRefFuture<T>
Returns a Future that resolves when the computation is finished, and accesses the inner
value by reference rather than by cloning it.
Trait Implementations§
Source§impl<T> Clone for LocalResource<T>
impl<T> Clone for LocalResource<T>
Source§impl<T> DefinedAt for LocalResource<T>
impl<T> DefinedAt for LocalResource<T>
Source§fn defined_at(&self) -> Option<&'static Location<'static>>
fn defined_at(&self) -> Option<&'static Location<'static>>
Returns the location at which the signal was defined. This is usually simply
None in
release mode.Source§impl<T> Deref for LocalResource<T>
impl<T> Deref for LocalResource<T>
Source§impl<T: 'static> From<ArcLocalResource<T>> for LocalResource<T>
impl<T: 'static> From<ArcLocalResource<T>> for LocalResource<T>
Source§fn from(arc: ArcLocalResource<T>) -> Self
fn from(arc: ArcLocalResource<T>) -> Self
Converts to this type from the input type.
Source§impl<T: 'static> From<LocalResource<T>> for ArcLocalResource<T>
impl<T: 'static> From<LocalResource<T>> for ArcLocalResource<T>
Source§fn from(local: LocalResource<T>) -> Self
fn from(local: LocalResource<T>) -> Self
Converts to this type from the input type.
Source§impl<T> IntoFuture for LocalResource<T>where
T: Clone + 'static,
impl<T> IntoFuture for LocalResource<T>where
T: Clone + 'static,
Source§type IntoFuture = AsyncDerivedFuture<T>
type IntoFuture = AsyncDerivedFuture<T>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<T: 'static> IsDisposed for LocalResource<T>
impl<T: 'static> IsDisposed for LocalResource<T>
Source§fn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
If
true, the signal cannot be accessed without a panic.Source§impl<T> Notify for LocalResource<T>where
T: 'static,
impl<T> Notify for LocalResource<T>where
T: 'static,
Source§impl<T> ReactiveNode for LocalResource<T>where
T: 'static,
impl<T> ReactiveNode for LocalResource<T>where
T: 'static,
Source§fn mark_dirty(&self)
fn mark_dirty(&self)
Notifies the source’s dependencies that it has changed.
Source§fn mark_check(&self)
fn mark_check(&self)
Notifies the source’s dependencies that it may have changed.
Source§fn mark_subscribers_check(&self)
fn mark_subscribers_check(&self)
Marks that all subscribers need to be checked.
Source§fn update_if_necessary(&self) -> bool
fn update_if_necessary(&self) -> bool
Regenerates the value for this node, if needed, and returns whether
it has actually changed or not.
Source§impl<T> ReadUntracked for LocalResource<T>where
T: 'static,
impl<T> ReadUntracked for LocalResource<T>where
T: 'static,
Source§type Value = ReadGuard<Option<T>, Mapped<AsyncPlain<SendOption<T>>, Option<T>>>
type Value = ReadGuard<Option<T>, Mapped<AsyncPlain<SendOption<T>>, Option<T>>>
The guard type that will be returned, which can be dereferenced to the value.
Source§fn try_read_untracked(&self) -> Option<Self::Value>
fn try_read_untracked(&self) -> Option<Self::Value>
Returns the guard, or
None if the signal has already been disposed.Source§fn read_untracked(&self) -> Self::Value
fn read_untracked(&self) -> Self::Value
Returns the guard. Read more
Source§fn custom_try_read(&self) -> Option<Option<Self::Value>>
fn custom_try_read(&self) -> Option<Option<Self::Value>>
This is a backdoor to allow overriding the
Read::try_read implementation despite it being auto implemented. Read moreSource§impl<T> Source for LocalResource<T>where
T: 'static,
impl<T> Source for LocalResource<T>where
T: 'static,
Source§fn add_subscriber(&self, subscriber: AnySubscriber)
fn add_subscriber(&self, subscriber: AnySubscriber)
Adds a subscriber to this source’s list of dependencies.
Source§fn remove_subscriber(&self, subscriber: &AnySubscriber)
fn remove_subscriber(&self, subscriber: &AnySubscriber)
Removes a subscriber from this source’s list of dependencies.
Source§fn clear_subscribers(&self)
fn clear_subscribers(&self)
Remove all subscribers from this source’s list of dependencies.
Source§impl<T> Subscriber for LocalResource<T>where
T: 'static,
impl<T> Subscriber for LocalResource<T>where
T: 'static,
Source§fn add_source(&self, source: AnySource)
fn add_source(&self, source: AnySource)
Adds a subscriber to this subscriber’s list of dependencies.
Source§fn clear_sources(&self, subscriber: &AnySubscriber)
fn clear_sources(&self, subscriber: &AnySubscriber)
Clears the set of sources for this subscriber.
Source§impl<T> ToAnySource for LocalResource<T>where
T: 'static,
impl<T> ToAnySource for LocalResource<T>where
T: 'static,
Source§fn to_any_source(&self) -> AnySource
fn to_any_source(&self) -> AnySource
Converts this type to its type-erased equivalent.
Source§impl<T> ToAnySubscriber for LocalResource<T>where
T: 'static,
impl<T> ToAnySubscriber for LocalResource<T>where
T: 'static,
Source§fn to_any_subscriber(&self) -> AnySubscriber
fn to_any_subscriber(&self) -> AnySubscriber
Converts this type to its type-erased equivalent.
Source§impl<T> Write for LocalResource<T>where
T: 'static,
impl<T> Write for LocalResource<T>where
T: 'static,
Source§fn try_write(&self) -> Option<impl UntrackableGuard<Target = Self::Value>>
fn try_write(&self) -> Option<impl UntrackableGuard<Target = Self::Value>>
Returns the guard, or
None if the signal has already been disposed.Source§fn try_write_untracked(&self) -> Option<impl DerefMut<Target = Self::Value>>
fn try_write_untracked(&self) -> Option<impl DerefMut<Target = Self::Value>>
or
None if the signal has already been disposed.Source§fn write(&self) -> impl UntrackableGuard
fn write(&self) -> impl UntrackableGuard
Returns the guard. Read more
Source§fn write_untracked(&self) -> impl DerefMut
fn write_untracked(&self) -> impl DerefMut
Returns a guard that will not notify subscribers when dropped. Read more
impl<T> Copy for LocalResource<T>
Auto Trait Implementations§
impl<T> Freeze for LocalResource<T>
impl<T> RefUnwindSafe for LocalResource<T>
impl<T> Send for LocalResource<T>
impl<T> Sync for LocalResource<T>
impl<T> Unpin for LocalResource<T>
impl<T> UnwindSafe for LocalResource<T>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read for Twhere
T: Track + ReadUntracked,
Source§impl<T> Set for Twhere
T: Update + IsDisposed,
impl<T> Set for Twhere
T: Update + IsDisposed,
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.
Source§impl<T> Update for Twhere
T: Write,
impl<T> Update for Twhere
T: Write,
Source§fn try_maybe_update<U>(
&self,
fun: impl FnOnce(&mut <T as Update>::Value) -> (bool, U),
) -> Option<U>
fn try_maybe_update<U>( &self, fun: impl FnOnce(&mut <T as Update>::Value) -> (bool, U), ) -> Option<U>
Updates the value of the signal, notifying subscribers if the update function returns
(true, _), and returns the value returned by the update function,
or None if the signal has already been disposed.Source§fn update(&self, fun: impl FnOnce(&mut Self::Value))
fn update(&self, fun: impl FnOnce(&mut Self::Value))
Updates the value of the signal and notifies subscribers.
Source§impl<T> UpdateUntracked for Twhere
T: Write,
impl<T> UpdateUntracked for Twhere
T: Write,
Source§fn try_update_untracked<U>(
&self,
fun: impl FnOnce(&mut <T as UpdateUntracked>::Value) -> U,
) -> Option<U>
fn try_update_untracked<U>( &self, fun: impl FnOnce(&mut <T as UpdateUntracked>::Value) -> U, ) -> Option<U>
Updates the value by applying a function, returning the value returned by that function,
or
None if the signal has already been disposed.
Does not notify subscribers that the signal has changed.Source§impl<T> With for Twhere
T: Read,
impl<T> With for Twhere
T: Read,
Source§type Value = <<T as Read>::Value as Deref>::Target
type Value = <<T as Read>::Value as Deref>::Target
The type of the value contained in the signal.
Source§impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
impl<T> WithUntracked for Twhere
T: DefinedAt + ReadUntracked,
Source§type Value = <<T as ReadUntracked>::Value as Deref>::Target
type Value = <<T as ReadUntracked>::Value as Deref>::Target
The type of the value contained in the signal.
Source§fn try_with_untracked<U>(
&self,
fun: impl FnOnce(&<T as WithUntracked>::Value) -> U,
) -> Option<U>
fn try_with_untracked<U>( &self, fun: impl FnOnce(&<T as WithUntracked>::Value) -> U, ) -> Option<U>
Applies the closure to the value, and returns the result,
or
None if the signal has already been disposed.