hampus
hampus
SSolara
Created by hampus on 7/9/2024 in #questions-issues
Best practices for state management and encapsulation
I am trying to figure out how to handle application state in a pythonic and scalable way. I don't like having global (reactive) variables, and I would like to encapsulate as much logic as possible into the components to separate concerns. 1. Is there any way for components to access reactives (solara.reactive or solara.use_state) on other components? 2. Can components be classes, or in some other way carry methods / properties / reactives in order to encapsulate behaviour? (eg general form of question above) 3. Are there examples/docs/instructions for how to create complex application states to be shared between components? I'm envisaging the application state as a big, nested dict that contains all state. 4. Is component state better managed by having a module per component that defines one or more reactives and their manipulation functions together with the component itself, so that you would import my_component and then use my_component.MyComponent, my_component.data and my_component.update_data(new_data)?
4 replies