Suppose, my application consists of many components, where users need to fill theirs information, something like this:
-Select city
`-Select library
`-Select book
`-... a lot of components like above
So, application has determined data flow, first user need to select city, then library, then book, etc.
The data flow looks like this, for example, when user chooses city, in next step, there will be list of libraries specially for chosen city, then user selects library, and list of books in chosen library will be shown respectively.
The problem is, that when user has selected city, library and book, he wants to choose another city, it must load again libraries, obviously, then what should I do in application with selected book, other selected components? I understand, need to reset them, set selected book to null, whatever the reset works.
However, do I really need to manually describe all steps, like in pseudocode:
onCitySelected(selectedCity) {
currentCity = selectedCity;
getLibraries(selectedCity);
resetBooks();
//reset...
//a lot of reset functions...
}
?
How can I avoid such verbose code, which application design should I use?
I'm using React+Redux, if it helps.