-
Notifications
You must be signed in to change notification settings - Fork 567
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
First cut at request_update #1128
Conversation
Fixes #1073. This version is largely for discussion, as it hasn't been tested at all.
druid/src/contexts.rs
Outdated
/// | ||
/// After this, `update` will be called on the widget in the next update cycle, even | ||
/// if there's not a data change. | ||
pub fn request_update<T, W>(&mut self) { |
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.
Generic parameters aren't needed here
This does now work for e.g Tabs in my binding-scroll branch |
Remove the `request_update_child` variant, as it likely won't be used. Add changelog.
I forgot a commit number was already assigned, as this was in draft. Also remove generic parameters, as per review.
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.
If this is a case we need to support (and zulip conversation is convincing), then this patch looks good to me, modulo some slightly scarier docs.
druid/src/tests/mod.rs
Outdated
if let Event::Command(cmd) = event { | ||
if cmd.is(REQUEST_UPDATE) { | ||
ctx.request_update(); | ||
} |
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 would now probably write this as,
if matches!(event, Event::Command(cmd) if cmd.is(REQUEST_UPDATE)) {
ctx.request_update();
}
but either works I think.
/// Request an update cycle. | ||
/// | ||
/// After this, `update` will be called on the widget in the next update cycle, even | ||
/// if there's not a data change. |
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 it's worth highlighting that this method is only exposed for special cases, such as when a container widget is synthesizing data for its children, and that in general it should be unnecessary/avoided.
assert!(!updated.get()); | ||
harness.submit_command(REQUEST_UPDATE, None); | ||
assert!(updated.get()); | ||
}) |
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.
nice to see how straight forward and readable this is.
Fixes #1073. This version is largely for discussion, as it hasn't been
tested at all.