Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part 2 following #264.
There was a significant question here: what format widget identifiers should take and what properties are required. This was already considered in #264, but to complete part 2 the design document was revised. Notable excerpts follow.
We must choose whether event handling happens via (selective) broadcast or targeted search. Previously targeted search was chosen for performance scaling, but in retrospect this was a poor goal. Detailed review found a couple of subtle issues:
SendEvent::send
to use selective-broadcast increases complexity slightly, but isn't a big deal.WidgetId
should always represent the full path, or we need a separate "identifier" system for Tab-navigation.ListView
and similar widgets to not use sequential identifiers and recommend that the plainList
not be used for insertion/deletion from the middle, though this is not ideal.With this in mind, three options for
WidgetId
are apparent:WidgetId
is notCopy
)It is possible that new
WidgetId
s would be generated frequently (e.g. scrolling a largeListView
), thus option (1) is not a good idea. While havingWidgetId: Copy
is (very) nice, clones remain cheap with option (2), and implementation turned out to be less intrusive than feared.Note: due to reference counting,
WidgetId
is now!Send
and!Sync
. This could be fixed with atomic reference counting, but seems unnecessary: the UI is usually restricted to a single thread (other threads can still wake subscribed widgets via update handles).Unsolved from #264 :
PartialEq for WidgetId
panics on invalid id": this revealed a subtle bug where input event handling could happen before newly-created widgets are configured. While this had no serious side-effects, it is unintended and could perhaps cause annoying-to-debug issues. Thus, panic on invalid id remains.WidgetId::opt_from_u64
with a bad value could cause a panic": this method is now markedunsafe
(since it could now cause a seg-fault). It could be removed entirely (no remaining usage), but is left for now.