Do not mark unchanged computed var deps as dirty#4488
Do not mark unchanged computed var deps as dirty#4488benedikt-bartscher wants to merge 11 commits intoreflex-dev:mainfrom
Conversation
masenf
left a comment
There was a problem hiding this comment.
one potentially issue i see with this approach is it makes it harder to manually mark a var as dirty, for example if internal change tracking is not working for a certain kind of object, a hackaround was always to assign it to itself to signal to the framework that it should be included in the delta. i know @adhami3310 uses this trick quite a bit.
|
@masenf I knew this comment was coming 😆 However, I have 2 arguments against it:
|
|
I just refactored one small repo to always check if the var has changed before assignment. Now I have a diff of 85 lines with repetitive if self.var != new_var:
self.var = new_var |
|
haven't looked into this too deeply but |
|
current implementation is not optimal, i have a better one coming |
|
need to recheck order of computed var computation |
Merge remote-tracking branch 'origin/main' into unchanged-vars-dirty
It changed due to priming of the caches. I disabled it for now in cc6edf1 This broke some of our apps without failing reflex tests. Maybe we can add a test for it (order and count of computed var execution) Not sure why the last commit broke dynamic route var tests. My test project which I wrote while fixing var deps for dynamic args with @masenf still works fine. Maybe the test only needs adjustment. Need to investigate (I don't just want to change it without fully understanding it) |
|
@masenf can you test if your model recursion issue also occurs with a computed var in this PR? |
|
Thank you for contributing to Reflex. I am closing this old or stale PR for now, but please refresh and reopen it if you believe this issue is still relevant. With the State refactoring, dirty var status will be stored in an "EventContext" rather than in the class itself. This should make it easier to handle checking whether a variable is actually dirty and should be recalculated. Since the underlying code is going through quite a bit of change, will be closing this one for now, but will incorporate the ideas to reduce delta size where possible. |
part of #4487