As your app grows, your state will grow too. You can split your state into multiple substates from your base state to keep things organized.
Creating a Substate
Your base state should inherit from
rx.State. Substates can either inherit from your base state or other substates.
checked: bool = True
count: int = 0
value: int = 42
color: str = "red"
text: str = "Hello World"
In the example above, we have a base state
ParentState with two substates
ChildState3 inherits from
ChildState1. Components can access any var or event handler from any substate.
A common use case may be to create a substate for each page of your app, while keeping general vars such as the logged in user in the base state for easy access.
Accessing Parent State Properties
You can access the parent state properties from a child substate, however you cannot access the child properties from the parent state.