pub struct Task { /* private fields */ }
Expand description
A task’s unique identifier.
Task
is a unique identifier for a task that has been spawned onto the runtime. It can be used to cancel the task
Implementations§
Source§impl Task
impl Task
Sourcepub fn new(task: impl Future<Output = ()> + 'static) -> Self
pub fn new(task: impl Future<Output = ()> + 'static) -> Self
Start a new future on the same thread as the rest of the VirtualDom.
This future will not contribute to suspense resolving, so you should primarily use this for reacting to changes and long running tasks.
Whenever the component that owns this future is dropped, the future will be dropped as well.
Spawning a future onto the root scope will cause it to be dropped when the root component is dropped - which will only occur when the VirtualDom itself has been dropped.
Sourcepub fn cancel(self)
pub fn cancel(self)
Drop the task immediately.
This does not abort the task, so you’ll want to wrap it in an abort handle if that’s important to you
Sourcepub fn set_active(&self, active: bool)
pub fn set_active(&self, active: bool)
Set the task as active or paused.