Skip to content

Instantly share code, notes, and snippets.

@paxbun
Created January 11, 2021 14:52
Show Gist options
  • Save paxbun/ec2909ed79535586418e62676a9d5f3b to your computer and use it in GitHub Desktop.
Save paxbun/ec2909ed79535586418e62676a9d5f3b to your computer and use it in GitHub Desktop.
Rust wasm sleep example
#[wasm_bindgen]
pub fn sleep(ms: i32) -> js_sys::Promise {
js_sys::Promise::new(&mut |resolve, _| {
web_sys::window()
.unwrap()
.set_timeout_with_callback_and_timeout_and_arguments_0(&resolve, ms)
.unwrap();
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment