pub struct UseTask<T>{ /* private fields */ }Expand description
The heavy-work idiom: AsyncValue state,
use_task (the blessed load/compute helper), UseTask handle, and
spawn_blocking (the CPU-bound entry point) — Frust’s counterpart to
Flutter’s compute()/FutureBuilder, with explicit cancellation on
component teardown. spawn_blocking joins the existing
spawn/spawn_local routing pair (async IO / UI-thread !Send /
one-off CPU work). App crates need no new dependency: this is the whole
heavy-work surface. See frust_reactive::task for the threading contract.
The handle use_task returns: a read handle to the task’s
AsyncValue<T> state plus a restart/refresh trigger.
Read the state reactively via signal (or the Get
trait on it) from Component::build; call restart to
re-run the fetch (e.g. a pull-to-refresh).
Implementations§
Source§impl<T> UseTask<T>
impl<T> UseTask<T>
Sourcepub fn signal(&self) -> RwSignal<AsyncValue<T>>
pub fn signal(&self) -> RwSignal<AsyncValue<T>>
The reactive state signal. Read it with the Get trait
(task.signal().get()) inside a tracked Component::build so a state
transition wakes the shell.
Sourcepub fn restart(&self)
pub fn restart(&self)
Re-runs the fetch: transitions the state to
Loading (carrying the current value for
refresh-without-flicker), aborts any in-flight background task, and
starts a fresh one. Last-write-wins by generation, so a restart storm
settles on the newest fetch’s result regardless of completion order.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for UseTask<T>
impl<T> !Send for UseTask<T>
impl<T> !Sync for UseTask<T>
impl<T> !UnwindSafe for UseTask<T>
impl<T> Freeze for UseTask<T>
impl<T> Unpin for UseTask<T>
impl<T> UnsafeUnpin for UseTask<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
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.