fix: update imports and methods

This commit is contained in:
Greg Johnston 2024-06-30 07:05:04 -04:00
parent 381ff8a7b0
commit 180511e9bb
2 changed files with 11 additions and 2 deletions

View File

@ -12,8 +12,8 @@ use futures::Future;
use hydration_context::SerializedDataId;
use reactive_graph::{
computed::{
ArcAsyncDerived, ArcAsyncDerivedFuture, ArcAsyncDerivedRefFuture,
ArcMemo, AsyncDerived, AsyncDerivedFuture, AsyncDerivedRefFuture,
ArcAsyncDerived, ArcMemo, AsyncDerived, AsyncDerivedFuture,
AsyncDerivedRefFuture,
},
graph::{Source, ToAnySubscriber},
owner::Owner,

View File

@ -111,6 +111,7 @@ where
}
impl<T: 'static> ArcAsyncDerived<T> {
#[track_caller]
pub fn by_ref(&self) -> AsyncDerivedRefFuture<T> {
AsyncDerivedRefFuture {
source: self.to_any_source(),
@ -121,6 +122,14 @@ impl<T: 'static> ArcAsyncDerived<T> {
}
}
impl<T: 'static> AsyncDerived<T> {
#[track_caller]
pub fn by_ref(&self) -> AsyncDerivedRefFuture<T> {
let this = self.inner.get().unwrap_or_else(unwrap_signal!(self));
this.by_ref()
}
}
/// A [`Future`] that is ready when an [`ArcAsyncDerived`] is finished loading or reloading,
/// and yields an [`AsyncDerivedGuard`] that dereferences to its value.
pub struct AsyncDerivedRefFuture<T> {