Reactice watch is not necessarily called when the underlying object changes #2193
Unanswered
samwareing
asked this question in
Q&A
Replies: 1 comment 2 replies
-
That's the expected behaviour at the moment. Reactives will only detect changes when you set a new value, not when you mutate an existing value. You can do |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This issue occurs because of the assumption that the object a
reactive
watches will only change value when the__set__
operator is called on thereactive
.If I have an object that has a deeper structue, or can be changed by calling a function in some way, I would expect
reactive
to know that it something has changed and call the watch function.In the example below, I have created a
reactive
that watches adataclass
object that is able to change itself via a theinitialise_my_types
method.I then call that method via a
textual
action, and I can see the underlying value change in my debugger, but the watch function is not called and therefore the displayed value is out of date.The following screenshots show the value changing. There is a breakpoint in the watch function that is never hit.
Textual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
Beta Was this translation helpful? Give feedback.
All reactions