Scope widget cherry-picked from binding-scroll branch.#1151
Scope widget cherry-picked from binding-scroll branch.#1151jneem merged 5 commits intolinebender:masterfrom
Conversation
348ee13 to
6dafc0f
Compare
jneem
left a comment
There was a problem hiding this comment.
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.
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.
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? |
raphlinus
left a comment
There was a problem hiding this comment.
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.
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.
I ran rustfmt on the example so it looks standardised now
# Conflicts: # CHANGELOG.md
jneem
left a comment
There was a problem hiding this comment.
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 |
As discussed many times on Zulip.
Scope allows you to encapsulate data so local reactivity is possible without polluting your global app state.