mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 09:54:41 -05:00
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user