Page state management with cascading events #3276
Unanswered
PawelRoman
asked this question in
Q&A
Replies: 1 comment
-
Hi @PawelRoman, This sounds like quite a complex scenario. Can you, please, try to create a minimum reproducible code example? This would allow us and the community to help more efficiently. Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Question
I wrote myself a class-based pages mini-framework, where each NiceGUI page is a class. Event handlers are class methods. I also have page state object - basically it's a self.state attribute on the class which stores a pydantic model. All UI controls bind to fields on the state object. I never change the controls values dynamically, I modify the state instead and the UI controls re-render themselves automatically.
Everything worked very nicely until I had to do a bit more complicated scenario, where dropdown's on_change event makes a change in the state object which triggers another dropdown's on_change. For some reason the second dropdown's event handler function does not see the value set in the page state object by the first event handler. It's as if the second event handler created some kind of a separate context or something like that.
Is there any kind of example or documentation on how to work with this type of more complex scenario where functions
which handle event "chains" need to share the same state?
Beta Was this translation helpful? Give feedback.
All reactions