You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make gloo::timer's future-based API like std / tokio.
Motivation
Why are we doing this? What problems does it solve?
This issue purposes to make gloo::timer's design more like Rust's standard library.
There was a similar discussion for the tokio library years ago about making the Tokio's sleep / timeout design to be similar to the standard library's design.
It's more familiar with people coming from other Rust areas.
The std::thread::sleep takes a Duration which is a better design than taking a number in millisecond in my opinion.
gloo::timer::sleep(Duration::from_secs(1)).await is easier to understand and remember than gloo::timer::TimeoutFuture::new(1000).await for most people.
Detailed Explanation
asyncfnsleep(duration:Duration){// ...}
Drawbacks, Rationale, and Alternatives
Does this design have drawbacks?
It breaks compatibility.
Are there alternative approaches?
The current approach of gloo::timer.
Why is this design the best of all designs available?
This is a design that meets the expectation for people coming from both Rust and other common programming languages.
What prior art exists?
This is the design used by std and tokio.
The text was updated successfully, but these errors were encountered:
futursolo
changed the title
Make gloo::times
Make gloo::timer 's design like stdlib
Oct 31, 2021
futursolo
changed the title
Make gloo::timer 's design like stdlib
Make gloo::timer's future-based design like stdlib
Oct 31, 2021
Summary
Make
gloo::timer
's future-based API likestd
/tokio
.Motivation
Why are we doing this? What problems does it solve?
This issue purposes to make gloo::timer's design more like Rust's standard library.
There was a similar discussion for the tokio library years ago about making the Tokio's sleep / timeout design to be similar to the standard library's design.
tokio-rs/tokio#2770
tokio-rs/tokio#2826
The rationale:
std::thread::sleep
takes aDuration
which is a better design than taking a number in millisecond in my opinion.gloo::timer::sleep(Duration::from_secs(1)).await
is easier to understand and remember thangloo::timer::TimeoutFuture::new(1000).await
for most people.Detailed Explanation
Drawbacks, Rationale, and Alternatives
Does this design have drawbacks?
It breaks compatibility.
Are there alternative approaches?
The current approach of
gloo::timer
.Why is this design the best of all designs available?
This is a design that meets the expectation for people coming from both Rust and other common programming languages.
What prior art exists?
This is the design used by
std
andtokio
.The text was updated successfully, but these errors were encountered: