fix: ensure task::spawn maintains reactive ownership (closes #4203) (#4206)

This commit is contained in:
Greg Johnston
2025-08-09 15:30:23 -04:00
committed by GitHub
parent b986fe11dc
commit 30dbb7ccc8

View File

@@ -301,12 +301,17 @@ pub mod logging {
/// Utilities for working with asynchronous tasks.
pub mod task {
use any_spawner::Executor;
use reactive_graph::computed::ScopedFuture;
use std::future::Future;
/// Spawns a thread-safe [`Future`].
///
/// This will be run with the current reactive owner and observer using a [`ScopedFuture`].
#[track_caller]
#[inline(always)]
pub fn spawn(fut: impl Future<Output = ()> + Send + 'static) {
let fut = ScopedFuture::new(fut);
#[cfg(not(target_family = "wasm"))]
Executor::spawn(fut);