瀏覽代碼

Merge pull request #153 from DioxusLabs/jk/spawn-future

feat: add "spawn" method for futures
Jonathan Kelley 3 年之前
父節點
當前提交
732ec018c3
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      packages/core/src/scopes.rs

+ 5 - 0
packages/core/src/scopes.rs

@@ -751,6 +751,11 @@ impl ScopeState {
         self.tasks.push_fut(fut)
     }
 
+    /// Spawns the future but does not return the TaskId
+    pub fn spawn(&self, fut: impl Future<Output = ()> + 'static) {
+        self.push_future(fut);
+    }
+
     // todo: attach some state to the future to know if we should poll it
     pub fn remove_future(&self, id: TaskId) {
         self.tasks.remove_fut(id);