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>
Sourcepub fn new<Fut>(fetcher: impl Fn() -> Fut + 'static) -> LocalResource<T>where
T: 'static,
Fut: Future<Output = T> + 'static,
pub fn new<Fut>(fetcher: impl Fn() -> Fut + 'static) -> LocalResource<T>where
T: 'static,
Fut: Future<Output = T> + 'static,
Creates the resource.
This will only begin loading data if you are on the client (i.e., if you do not have the
ssr feature activated).
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§fn clone(&self) -> LocalResource<T>
fn clone(&self) -> LocalResource<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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>>
None in
release mode.Source§impl<T> Deref for LocalResource<T>
impl<T> Deref for LocalResource<T>
Source§type Target = AsyncDerived<T>
type Target = AsyncDerived<T>
Source§impl<T> From<ArcLocalResource<T>> for LocalResource<T>where
T: 'static,
impl<T> From<ArcLocalResource<T>> for LocalResource<T>where
T: 'static,
Source§fn from(arc: ArcLocalResource<T>) -> LocalResource<T>
fn from(arc: ArcLocalResource<T>) -> LocalResource<T>
Source§impl<T> From<LocalResource<T>> for ArcLocalResource<T>where
T: 'static,
impl<T> From<LocalResource<T>> for ArcLocalResource<T>where
T: 'static,
Source§fn from(local: LocalResource<T>) -> ArcLocalResource<T>
fn from(local: LocalResource<T>) -> ArcLocalResource<T>
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>
Source§fn into_future(self) -> <LocalResource<T> as IntoFuture>::IntoFuture
fn into_future(self) -> <LocalResource<T> as IntoFuture>::IntoFuture
Source§impl<T> IsDisposed for LocalResource<T>where
T: 'static,
impl<T> IsDisposed for LocalResource<T>where
T: 'static,
Source§fn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
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)
Source§fn mark_check(&self)
fn mark_check(&self)
Source§fn mark_subscribers_check(&self)
fn mark_subscribers_check(&self)
Source§fn update_if_necessary(&self) -> bool
fn update_if_necessary(&self) -> bool
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>>>
Source§fn try_read_untracked(
&self,
) -> Option<<LocalResource<T> as ReadUntracked>::Value>
fn try_read_untracked( &self, ) -> Option<<LocalResource<T> as ReadUntracked>::Value>
None if the signal has already been disposed.Source§fn read_untracked(&self) -> Self::Value
fn read_untracked(&self) -> Self::Value
Source§fn custom_try_read(&self) -> Option<Option<Self::Value>>
fn custom_try_read(&self) -> Option<Option<Self::Value>>
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)
Source§fn remove_subscriber(&self, subscriber: &AnySubscriber)
fn remove_subscriber(&self, subscriber: &AnySubscriber)
Source§fn clear_subscribers(&self)
fn clear_subscribers(&self)
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)
Source§fn clear_sources(&self, subscriber: &AnySubscriber)
fn clear_sources(&self, subscriber: &AnySubscriber)
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
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
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>
fn try_write(&self) -> Option<impl UntrackableGuard>
None if the signal has already been disposed.Source§fn try_write_untracked(&self) -> Option<impl DerefMut>
fn try_write_untracked(&self) -> Option<impl DerefMut>
None if the signal has already been disposed.Source§fn write(&self) -> impl UntrackableGuard
fn write(&self) -> impl UntrackableGuard
Source§fn write_untracked(&self) -> impl DerefMut
fn write_untracked(&self) -> impl DerefMut
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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 moreSource§impl<T, S> IntoOptionGetter<T, SignalMarker> for S
impl<T, S> IntoOptionGetter<T, SignalMarker> for S
Source§fn into_option_getter(self) -> OptionGetter<T>
fn into_option_getter(self) -> OptionGetter<T>
OptionGetter.Source§impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read for Twhere
T: Track + ReadUntracked,
Source§impl<T> SerializableKey for T
impl<T> SerializableKey for T
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
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
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>
(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))
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>
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
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
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>
None if the signal has already been disposed.