-
-
Notifications
You must be signed in to change notification settings - Fork 809
Open
Milestone
Description
I think that the next functions should be renamed in a breaking change, replacing their counterparts without handles:
request_animation_frame_with_handle->request_animation_framerequest_idle_callback_with_handle->request_idle_callbackset_interval_with_handle->set_intervalset_timeout_with_handle->set_timeout
Due to several reasons:
with_handleis very confusing. In Leptos the suffixwith_handlemeans that the function returns a handle, but in web-sys it means that it accepts a handle. Seeclear_timeout_with_handleandclear_interval_with_handle. Note thatwith_handlein web-sys is used exclusively to differentiate the functions from their counterparts that don't accept a handle. As proof,cancel_animation_frameaccepts a handle but is not named_with_handlebecause it is implicit that cancelling needs something to be cancelled.- All the implementations of the above functions without handles are just syntactic sugar for
_ = *_with_handle, so it would be more ergonomic just_ = *when the handle is discarded. IMO, it is preferable to call_ = set_timeoutthan needing to call another function when it should return a handle. That's more aligned with JavaScript behavior, as the handle is always returned. - Probably it is faster, at least in compile times, because it would remove an intermediate function when using functions without handles.
- Traditionally in the Rust ecosystem, it is much more common to use
_with_*for builders or for functions that accept an additional argument that differs from the original. I’ve never seen an API use_with_*to refer to a function that returns something different.
Metadata
Metadata
Assignees
Labels
No labels