CenterForTheBuiltEnvironment / comfort-dash

Revision of the CBE Comfort Tool using Dash.
2 stars 12 forks source link

State (data) handling #5

Closed t-kramer closed 1 month ago

t-kramer commented 2 months ago
t-kramer commented 2 months ago

@Echo11ovo @Ha02hen You can start doing some research on this.

Echo11ovo commented 2 months ago

I have completed the initial exploration, and now we have two potential approaches. As discussed in our previous meeting, we initially planned to divide pages based on functionality, using a URL structure like localhost:8050/single/[model_name]/[parameter value].

However, during implementation, I discovered that this routing approach presents some issues within the Dash framework. Specifically, the page refreshes constantly whenever a user inputs parameters, significantly disrupting the user's input experience. The root of this problem likely stems from Dash's lack of optimization for this type of dynamic URL structure in its route management.

My understanding is that in the Dash framework, especially in multi-page applications, a URL structure like /single/[model_name]/[parameter value] might be interpreted as querying for specific files or resources under the "single" directory. Consequently, whenever parameters in the URL change, the framework perceives this as a new resource request, triggering a full page reload.

Given this issue, we may need to reconsider our URL structure design. A possible alternative could be to use query parameters, for example:

localhost:8050/single?model=<model_name>&<parameter1>=<value1>&<parameter2>=<value2>

This approach might reduce unnecessary page refreshes, as changes in query parameters are typically not viewed as new routes. Additionally, this structure aligns better with RESTful API design principles and may integrate more smoothly with Dash's callback system.

And here are my suggestions for setting up route parameters for the other functionalities:

These URL structures provide a clear and intuitive way to represent different functionalities in your application, making it easier for users to understand and share specific views or comparisons.