feat: Add Handle::update_tracked for conditional rebuilds#32
Merged
Conversation
Add TrackedRef<'a, S>, a borrowing dirty-tracker that wraps &mut S. Reads through Deref or read() don't set the dirty flag; writes through DerefMut do. Handle::update_tracked() accepts a callback receiving &mut TrackedRef instead of &mut S. The application only marks itself dirty (triggering a rebuild) if the callback actually mutated state. This allows callers like input-change handlers to skip unnecessary rebuilds when the relevant state hasn't changed (e.g., is_input_blank stays false while typing additional characters). Handle::update() is unchanged and always triggers a rebuild.
Greptile SummaryAdds Confidence Score: 5/5Safe to merge — no logic issues found All three message-dispatch paths handle the new variant, TrackedRef's dirty semantics are correct, and the only rough edge (remainder still using the verbose guard in renderer.rs) is a pure style inconsistency with no behavioral impact. No files require special attention Important Files Changed
Reviews (1): Last reviewed commit: "Clippy" | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
TrackedRef<'a, S>, a borrowing dirty-tracker that wraps&mut S— reads throughDeref/read()don't set the dirty flag, writes throughDerefMutdoHandle::update_tracked()which only triggers a rebuild if the callback actually mutated stateHandle::update()is unchanged and always triggers a rebuildMotivation
In apps with expensive view functions, high-frequency state updates that don't actually change values (e.g., an input handler setting
is_input_blank = falsewhen it's already false) still trigger full rebuilds.update_trackedlets callers opt into conditional rebuilds:Test plan