pub struct ArcLocalResource<T> { /* private fields */ }Expand description
A reference-counted resource that only loads its data locally on the client.
Implementations§
Source§impl<T> ArcLocalResource<T>
impl<T> ArcLocalResource<T>
Sourcepub fn new<Fut>(fetcher: impl Fn() -> Fut + 'static) -> ArcLocalResource<T>where
T: 'static,
Fut: Future<Output = T> + 'static,
pub fn new<Fut>(fetcher: impl Fn() -> Fut + 'static) -> ArcLocalResource<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).
Sourcepub fn map<U>(&self, f: impl FnOnce(&SendWrapper<T>) -> U) -> Option<U>where
T: 'static,
pub fn map<U>(&self, f: impl FnOnce(&SendWrapper<T>) -> U) -> Option<U>where
T: 'static,
Synchronously, reactively reads the current value of the resource and applies the function
f to its value if it is Some(_).
Source§impl<T, E> ArcLocalResource<Result<T, E>>where
T: 'static,
E: Clone + 'static,
impl<T, E> ArcLocalResource<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.
Trait Implementations§
Source§impl<T> Clone for ArcLocalResource<T>
impl<T> Clone for ArcLocalResource<T>
Source§fn clone(&self) -> ArcLocalResource<T>
fn clone(&self) -> ArcLocalResource<T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> DefinedAt for ArcLocalResource<T>
impl<T> DefinedAt for ArcLocalResource<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> 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>
Converts to this type from the input type.
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>
Converts to this type from the input type.
Source§impl<T> IntoFuture for ArcLocalResource<T>where
T: Clone + 'static,
impl<T> IntoFuture for ArcLocalResource<T>where
T: Clone + 'static,
Source§type IntoFuture = Map<AsyncDerivedFuture<SendWrapper<T>>, fn(SendWrapper<T>) -> T>
type IntoFuture = Map<AsyncDerivedFuture<SendWrapper<T>>, fn(SendWrapper<T>) -> T>
Which kind of future are we turning this into?
Source§fn into_future(self) -> <ArcLocalResource<T> as IntoFuture>::IntoFuture
fn into_future(self) -> <ArcLocalResource<T> as IntoFuture>::IntoFuture
Creates a future from a value. Read more
Source§impl<T> IsDisposed for ArcLocalResource<T>where
T: 'static,
impl<T> IsDisposed for ArcLocalResource<T>where
T: 'static,
Source§fn is_disposed(&self) -> bool
fn is_disposed(&self) -> bool
If
true, the signal cannot be accessed without a panic.Source§impl<T> ReactiveNode for ArcLocalResource<T>
impl<T> ReactiveNode for ArcLocalResource<T>
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 ArcLocalResource<T>where
T: 'static,
impl<T> ReadUntracked for ArcLocalResource<T>where
T: 'static,
Source§type Value = ReadGuard<Option<SendWrapper<T>>, AsyncPlain<Option<SendWrapper<T>>>>
type Value = ReadGuard<Option<SendWrapper<T>>, AsyncPlain<Option<SendWrapper<T>>>>
The guard type that will be returned, which can be dereferenced to the value.
Source§fn try_read_untracked(
&self,
) -> Option<<ArcLocalResource<T> as ReadUntracked>::Value>
fn try_read_untracked( &self, ) -> Option<<ArcLocalResource<T> as ReadUntracked>::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 ArcLocalResource<T>
impl<T> Source for ArcLocalResource<T>
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 ArcLocalResource<T>
impl<T> Subscriber for ArcLocalResource<T>
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 ArcLocalResource<T>where
T: 'static,
impl<T> ToAnySource for ArcLocalResource<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 ArcLocalResource<T>where
T: 'static,
impl<T> ToAnySubscriber for ArcLocalResource<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.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ArcLocalResource<T>
impl<T> !UnwindSafe for ArcLocalResource<T>
impl<T> Freeze for ArcLocalResource<T>
impl<T> Send for ArcLocalResource<T>
impl<T> Sync for ArcLocalResource<T>
impl<T> Unpin for ArcLocalResource<T>
impl<T> UnsafeUnpin for ArcLocalResource<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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read for Twhere
T: Track + ReadUntracked,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SerializableAny for T
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
impl<T> WasmNotSend for Twhere
T: Send,
impl<T> WasmNotSendSync for Twhere
T: WasmNotSend + WasmNotSync,
impl<T> WasmNotSync for Twhere
T: Sync,
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> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
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.