Created
January 11, 2021 14:52
-
-
Save paxbun/ec2909ed79535586418e62676a9d5f3b to your computer and use it in GitHub Desktop.
Rust wasm sleep example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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