UC-Davis-molecular-computing / scadnano

Web application for designing DNA structures such as DNA origami.
https://scadnano.org
MIT License
22 stars 13 forks source link

restructure code to reduce dependencies #973

Open dave-doty opened 6 months ago

dave-doty commented 6 months ago

See https://github.com/google/built_value.dart/issues/1304

I'm not sure how feasible this is given the current architecture. As David Morgan said, we use this global variable app all over the place, so in some sense anywhere it's used essentially the whole project is being imported. But maybe it's possible to use packages to officially declare that the view depends on the model but not the other way around, for instance. Similarly the reducers depend on the model but not the other way around, and there's no dependence between the view and reducers.

Most of the usages of the global app variable are:

  1. Calling app.dispatch to dispatch an action. This is done through app because it stores the Redux stores.
  2. Accessing the AppState. This is typically done in code in view files, but not in React render methods, in keeping with the principle I explained here: https://stackoverflow.com/questions/62942644/how-to-make-a-react-component-intelligently-dispatch-a-redux-action-on-user-inte.

Unfortunately, these both in some sense seem to preclude splitting up the app variable into other smaller global variables. The first is needed to access the Redux stores, one of which stores the entire current AppState, and the second also requires accessing the current AppState, also through the main store.