hampus
hampus
SSolara
Created by hampus on 7/9/2024 in #questions-issues
Best practices for state management and encapsulation
Thank you for the reply. I could have verbalized by objection to global variables better. Specifically I'm trying to understand how to build an application where the user adds and removes components herself, so the components and their state have to be linked dynamically. 1. My reflex would be to pass Components to other Components, saying "this is the component you should interact with". In that way the parent component does not need to know how these components interact (i.e. how they share state). Practically, the follow-up question would be: in the Todo example you linked, can other component access the create_new_item() member of a TodoNew component? If so, is this a bad idea and why? 2. Are there any code examples for this? 3. It was useful but not sufficiently complex. I tested it and commented in the PR. I hope it will be helpful. 4. I'm starting to grasp that "state" is central concept here. It's just difficult to transition from OOP to this paradigm. I will play around with the TODO example and see if I can make it more complicated.
4 replies