-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
moved callback to leptos root and improved design #1795
Conversation
Thanks so much. I will definitely review before releasing 0.5. |
@rambip I'm curious to hear what you think of this one, which does implement Using the #[component]
fn MyComponent(#[prop(into)] render_number: Callback<(i32, i32), String>) -> impl IntoView {
view! {
<div>
{render_number(42, 37)}
// does the same thing
{render_number.call((42, 37))}
</div>
}
}
#[component]
pub fn App() -> impl IntoView {
view! {
<MyComponent render_number=|(x, y)| format!("x: {x} - y: {y}")/>
}
} |
I didn't manage to implement Please implement it for That said, It can be very counter-intuitive for users to write |
I switched back to the more obvious
|
Could |
I wrote it ! |
Nice changes! The callback type is basically back to its last state in leptonic. I would say as well that the "every callback is a stored vlaue and therefore copy" approach is the most ergonomic for all users. You immediately run into compiler errors if you try to use a non-copy callback in more than one place. But wasn't there a discussion about not storing each callback as a stored value for performance reasons? Did some preconditions change in 0.5 or am I wrong and this was generally deemed ok? |
Enough people argued against me and the difference is small enough that I just gave in 😄 |
This is a small update on
callback.rs
.The most noticeable change is the location of the code: it moved to
leptos
because it may be usefull outside of the browser.Another change: the suppression of
HtmlCallback
because now anyHtmlElement
implementsInto<HtmlElement<AnyElement>>
.I wanted to implement
Fn
for theCallable
trait, but 1) I was not able to do it because of unconstrained type parameters and 2) thecall
method onCallable
is the same as the call method onFn
, this is a bit dumb ...It would be really cool if this change could be accepted for 5.0, just for the fact that
HtmlCallback
andViewCallback
will never exist.