Conversion from state handlers / reducer dispatchers to callbacks #3510
Closed
its-the-shrimp
started this conversation in
Ideas
Replies: 2 comments
-
The fact they are fns under the hood is an implementation detail that can be used for optimization, your For the time being, you can write an extension trait in your project that does this for you. In cases you dont want to reuse the setter after, you can avoid a clone, and you dont need Also consider #3464. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Implemented in #3519. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
both
UseStateHandle
andUseReducerDispatcher
are currently nothing more than oneRc<dyn Fn>
, and I myself recently had a use case for a function that'd extract that function into a callback, what I had to opt for instead wasWhich is way too much code for what's supposed to be a single clone away, so my proposal is adding
UseStateSetter::callback(&self) -> Callback<T>
&UseReducerDispatcher::callback(&self) -> Callback<T>
What do you think? I'm ready to implement it myself if people agree
Beta Was this translation helpful? Give feedback.
All reactions