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)) 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