From d6b9f0501f304296fdb11a4c9d4c0e30f8cec00e Mon Sep 17 00:00:00 2001 From: Bao Zhiyuan Date: Sun, 9 Mar 2025 16:30:20 +0800 Subject: [PATCH 1/2] add spawn_detach --- src/js/async.mbt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/js/async.mbt b/src/js/async.mbt index c120c6d..5daae28 100644 --- a/src/js/async.mbt +++ b/src/js/async.mbt @@ -37,6 +37,17 @@ pub fn Promise::new[T](op : async () -> T!) -> Promise { Promise::new_ffi(fn() { Value::cast_from(op!!()) }) } +///| +pub fn spawn_detach[T, E : Error](op : async () -> T!E) -> Unit { + async_run(fn() { + try { + op!!() |> ignore + } catch { + _ => () + } + }) +} + ///| extern "js" fn Promise::new_ffi(op : async () -> Value!) -> Promise = #| (op) => new Promise((k, ke) => op(k, ke)) From d301933099620a6bc0a72ba462ecda216c7c35c6 Mon Sep 17 00:00:00 2001 From: Bao Zhiyuan Date: Mon, 10 Mar 2025 11:38:19 +0800 Subject: [PATCH 2/2] udpate moon info --- src/js/js.mbti | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/js.mbti b/src/js/js.mbti index b8350fd..dbb6433 100644 --- a/src/js/js.mbti +++ b/src/js/js.mbti @@ -19,6 +19,8 @@ let iterator : Symbol fn require(String, keys~ : Array[String] = ..) -> Value +fn spawn_detach[T, E : Error](() -> T!E) -> Unit + fn suspend[T, E : Error](((T) -> Unit, (E) -> Unit) -> Unit) -> T!E // Types and methods