-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Independent States #3206
Independent States #3206
Conversation
i think we need #2429 to solve this properly. the |
If my assumptions are correct, this should improve event handling performance for reflex-web quite decent. There are over 20 |
import reflex as rx
class StateA(rx.State):
a: str = ""
async def handle_click(self):
self.a = "foo"
state_b = await self.get_state(StateB)
state_b.b = "bar"
class StateB(rx.State):
b: str = ""
def index() -> rx.Component:
return rx.vstack(
rx.hstack(
StateA.a,
StateB.b
),
rx.button("Click me", on_click=StateA.handle_click)
)
app = rx.App()
app.add_page(index) In reflex With this proposed patch, the page only displays "foo". This is primarily why the delta is calculated from the root state, so that any states which are patched into the tree during processing of an event have their deltas also calculated. I definitely see what you're trying to do here; If I just have an |
Thanks, I completely missed |
Thankfully because computed vars use property semantics, they can only access vars in their immediate ancestors (without using hacks that we do not support). So the dependency tracking is already working i think. The problem is that for regular |
Thanks a lot, I should have looked into the dependency tracking implementation earlier... |
There have been several bugs initially in the dependency tracking that have since been fixed. It's possible that other bugs could be lurking, but i have not uncovered them yet and use I think it's ready to become the default, but that means we're relying on users to report bugs that might pop up related to computed vars in the next release. Additionally, it notably cannot track vars outside of |
I see, makes sense. Considering the possible performance impacts of I just migrated some codebases to cached var. If any problems arise, I will report them as usual. |
Closes #3204