Add static dependency injection to @computed_property for @emit support#3462
Merged
Add static dependency injection to @computed_property for @emit support#3462
@computed_property for @emit support#3462Conversation
@computed_property for @emit support
|
Performance benchmarks:
|
2f9209a to
7194959
Compare
7194959 to
7cae56d
Compare
quaquel
reviewed
Mar 9, 2026
quaquel
reviewed
Mar 9, 2026
quaquel
reviewed
Mar 9, 2026
quaquel
reviewed
Mar 9, 2026
quaquel
approved these changes
Mar 11, 2026
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
This PR adds static dependency injection to the
@computed_propertydecorator via a newdependencieskeyword argument. This allows derived states to manually subscribe to specific signals, explicitly supporting events generated by the@emitdecorator which are otherwise invisible to the reactive system.Motive
See #3227
Implementation
@computed_propertyto accept adependencieskwarg, which takes a list of tuples containing the target dependencies name and the specific signal types (or pass nothing forALLsentinel).ComputedState.__init__to parse thedependencieslist upon creation.ComputedStateactively registers itself with the target usingowner.observe(obs_name, signal_type, self._set_dirty). This bypasses the need for__get__auto-discovery and directly injects the cache invalidation trigger into the emitter's internalsubscribersdictionary.Usage Examples