feat: add useUITree hook for external patch sources #35
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.
useUITree Hook
Overview
This MR adds a new hook for iteratively managing UI tree state when patches come from external sources rather than a dedicated fetch endpoint.
Motivation
The existing
useUIStreamhook is tightly coupled to its own fetch lifecycle:The use case I am working on relies on supporting patches from non-api sources and iterating on an existing tree without incurring a full regeneration.
API
Notes
This would be 90% unnecessary if
applyPatchwas exported, but I wasn't sure if that change would be pattern-breaking / if it is better practice to expose a hook hereI purposefully avoided making changes to
useUIStream()to reduce scope, but if there is appetite for consolidating the tree management layer into its own exportable primitive and reusing it withinuseUIStream()I'm happy to work on that too.(Also happy to help with docs if this ends up being considered)