don't remove futures spawned by spawn_forever when the component is removed (#1708)

This commit is contained in:
ealmloff authored and GitHub committed 2024-01-03 14:02:36 -06:00
1 parent 43d9fe1ab0
commit 2e424436b3
1 file changed
+1 -11
+1 -11
View File
@@ -230,17 +230,7 @@ impl ScopeContext {
/// This is good for tasks that need to be run after the component has been dropped.
pub fn spawn_forever(&self, fut: impl Future<Output = ()> + 'static) -> TaskId {
// The root scope will never be unmounted so we can just add the task at the top of the app
let id = self.tasks.spawn(ScopeId::ROOT, fut);
// wake up the scheduler if it is sleeping
self.tasks
.sender
.unbounded_send(SchedulerMsg::TaskNotified(id))
.expect("Scheduler should exist");
self.spawned_tasks.borrow_mut().insert(id);
id
self.tasks.spawn(ScopeId::ROOT, fut)
}
/// Informs the scheduler that this task is no longer needed and should be removed.