-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Potential case for optional fallback in <Show> view macro tag #406
Comments
The question is whether it is clearer to show what the fallback case is, or to create some default. |
Ah, I was thinking more in terms of, we have a fallback. Do we enable a default fallback of an empty template. Allowing people to set a fallback if they want it, but not requiring a fallback if the fallback is nothingness. |
I think it's a good idea. I went to go do a quick implementation and realized why it's hard :-D The issue is that we can't have optional generic arguments. If you take a look at the current function signature pub fn Show<F, W, IV>(
/// The scope the component is running in
cx: Scope,
/// The components Show wraps
children: Box<dyn Fn(Scope) -> Fragment>,
/// A closure that returns a bool that determines whether this thing runs
when: W,
/// A closure that returns what gets rendered if the when statement is false
fallback: F,
) -> impl IntoView
where
W: Fn() -> bool + 'static,
F: Fn(Scope) -> IV + 'static,
IV: IntoView, If we make fallback This is one of those Rust things about needing to know how to lay things out in memory and therefore making things slightly less ergonomic. Maybe I'll add a note to the docs: if you want to show nothing for the fallback it's simply |
The templates tag requires a fallback. There are many cases where conditional data should be displayed with an empty fallback. I'm proposing the idea of making the fallback optional or to have an empty view be the default fallback.
Use cases include display of a sale badge, GDPR consent banners, etc.
Looking forward to hearing what you all think.
The text was updated successfully, but these errors were encountered: