-
Notifications
You must be signed in to change notification settings - Fork 126
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
xilem_core: Add a WithoutElements
ViewSequence
#608
base: main
Are you sure you want to change the base?
Conversation
I haven't had chance to review this yet. One thing I'm wondering is whether we can make an alternative for |
Good point. You mean to avoid the extra wrapper, and directly use the no element views in sequences? At least something like this: impl<V: View<State, Action, Context, Message, Element = NoElement> + NoElementViewMarker, ...>
ViewSequence<State, Action, Context, Element, Message> for V {} is not possible, because of ambiguity again... (We would need something like negative trait bounds?) The other possible idea I tried, is directly implementing the I'm not sure if it's worth it, but we could remove the super trait requirement Or do you mean something else? |
I mean, I was especially saying that we should do that investigation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A docs nits, but otherwise I think it's better to land this than not.
Sorry it's taken so long to review; this hasn't been on my critical path.
phantom: PhantomData<fn() -> (State, Action, Context, Message)>, | ||
} | ||
|
||
/// A [`ViewSequence`] that doesn't contain any elements, it can be used everywhere where a view sequence (with or without elements) is expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This documentation is very oblique; I know why it exists, but to someone stumbling upon this, it would likely be extremely mysterious.
Perhaps we should say something like:
An adapter which turns a [
ViewSequence
] containing any number of views with side effects, into aViewSequence
with any element type.This can be used to embed side-effects naturally into the flow of your program.
This can be used as an alternative to [fork
] , which avoids adding extra nesting at the cost of only being usable in places where there is already an existing sequence.
This is similar as the
fork
view, but it allows usingView
s/ViewSequence
s without elements within aViewSequence
context that contains elements, see #461 (comment) for the original motivation.Taking
xilem_web
as example, this should be possible (as well as something similar as in the linked comment):The
WidgetViewSequence
is "fixed" as well, by using the "right" widget type (DynWidget
is only used inAnyView
, whereas I thinkBox<dyn Widget>
is more general and correct).