Better approach to build a toolbar control

Not always easy to fine tune the right usage of every possibilities. After quite a lot of trial and errors I’ve found that the Store is very useful but should not be used to solved every problems.

From what you describe I guess that the Store would be a great fit to solve your toolbar situation. You can dynamically update the State with the buttons you need for each view. It’s typically a “State” issue because your buttons are a reflection of the current state of the application and what could possibly the next steps for the current user.

But when it comes to the core data that your application manages, it probably shouldn’t be all handled by the store. This might be better handled by the view directly or dedicated services.

I like the term “Stage” to help me decided what should be in the store or not. What kind of informations really describe the state of my application at a current time. What kind of things I would like to have directly available if the user refreshes the browser (before to make any API calls). I like to have the UX all available on refresh, even if I need to fetch data again from the API to populate the view.

BTW: I use localStorage to save the state so that I can get it on refresh…

Not sure if this is the best approach TBH. Learning every day new things… Hopefully we get better along the way…

3 Likes