Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/js/async.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions src/js/js.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down