-
Notifications
You must be signed in to change notification settings - Fork 568
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
Scope widget cherry-picked from binding-scroll branch. #1151
Conversation
348ee13
to
6dafc0f
Compare
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.
I was confused about a couple little things, but my main comment is that it would be really nice to have API docs for the public bits :)
druid/src/widget/scope.rs
Outdated
|
||
impl<SP: ScopePolicy, W: Widget<SP::State>> Widget<SP::In> for Scope<SP, W> { | ||
fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut SP::In, env: &Env) { | ||
if self.widget_added { |
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.
I don't understand the need for this check: not getting widget_added is bug, but it's a bug everywhere and we usually don't test for it explicitly. What goes wrong here that requires an explicit test?
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.
I think this may be a holdover from bugs with viewswitcher. Probably can go
I've not yet had the time to catch up on the Zulip discussion, and if I look at this right now, I have absolutely no idea what to do with it. Some docs and an example would be great I think. |
I was asked to extract it in its current state. Some of the motivating use cases are in the mentioned branch which I was told was too big to PR. I will do some docs eventually but that is why I did the PR. |
I understand that it will be convenient to do the example(s) later, but what about docs for the public API functions? |
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 seems good to me. Thanks for splitting it off! Also good to see the request_update propagation logic through Lens fixed.
druid/src/widget/scope.rs
Outdated
/// # Examples | ||
/// ``` | ||
/// #[derive(Data, Lens)] | ||
/// struct AppState{ |
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.
Minor formatting nits, there seem to be spaces missing; rustfmt apparently doesn't catch issues inside doctests, which seems to me an oversight.
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.
I ran rustfmt on the example so it looks standardised now
# Conflicts: # CHANGELOG.md
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.
Thanks for the nice docs! I found a missing apostrophe, but let's not hold this up for another CI cycle...
/// | ||
/// This is useful in circumstances where | ||
/// * A (potentially reusable) widget is composed of a tree of multiple cooperating child widgets | ||
/// * Those widgets communicate amongst themselves using Druids reactive data mechanisms |
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.
Druid's
As discussed many times on Zulip.
Scope allows you to encapsulate data so local reactivity is possible without polluting your global app state.