Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windowless sleep #757

Merged
merged 5 commits into from
Nov 8, 2023
Merged

Windowless sleep #757

merged 5 commits into from
Nov 8, 2023

Conversation

futurepaul
Copy link
Contributor

web-sys calls the "window" object for setTimeout, but that's not actually necessary (setTimeout is available in js environments without a window, like node). Also, it seems like the web-sys console_log is only used for tests, so with that we can move the web-sys dep entirely to dev-dependencies

this all seems to work fine in browser but I can't figure out how to run the tests on my mac

@benthecarman
Copy link
Collaborator

Is there a way we can do this without having to add javascript, or at least a library that does this for us?

@benthecarman
Copy link
Collaborator

This could be worth trying instead

https://docs.rs/async-std/latest/async_std/task/fn.sleep.html

@TonyGiorgio
Copy link
Contributor

Agreed, no js. Make it into a rust crate and we'll add it :P

web-sys calls the "window" object for setTimeout,

Why is this a problem though?

@benthecarman
Copy link
Collaborator

For Javascript environments that aren't a browser

@futurepaul
Copy link
Contributor Author

This could be worth trying instead

https://docs.rs/async-std/latest/async_std/task/fn.sleep.html

does this work with wasm? tried looking at the impl but I couldn't quite follow it

@futurepaul
Copy link
Contributor Author

Agreed, no js. Make it into a rust crate and we'll add it :P

web-sys calls the "window" object for setTimeout,

Why is this a problem though?

yeah this is helpful for WASI or node contexts, but also there's no "window" object in a web worker

@benthecarman
Copy link
Collaborator

does this work with wasm? tried looking at the impl but I couldn't quite follow it

idk, was hoping you'd test 😅

@futurepaul
Copy link
Contributor Author

idk, was hoping you'd test 😅

lol it's not if this tracking issue is real async-rs/async-std#220

@benthecarman benthecarman linked an issue Oct 15, 2023 that may be closed by this pull request
@benthecarman benthecarman force-pushed the windowless-sleep branch 2 times, most recently from 23d49c0 to 9cd5760 Compare October 16, 2023 19:47
@futurepaul
Copy link
Contributor Author

windowless_sleep = "0.1.1"

@TonyGiorgio
Copy link
Contributor

Is this good to merge? It would be good to remove local storage.

@benthecarman
Copy link
Collaborator

Should be okay

mutiny-wasm/src/utils.rs Outdated Show resolved Hide resolved
@TonyGiorgio
Copy link
Contributor

Needs rebase.

@benthecarman benthecarman merged commit 46b0194 into master Nov 8, 2023
9 checks passed
@benthecarman benthecarman deleted the windowless-sleep branch November 8, 2023 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove dependence on localstorage
3 participants