ui: Network Request Refactor #18741
Labels
A-webui-general
Issues on the DB Console that span multiple areas or don't have another clear category.
C-cleanup
Tech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.
no-issue-activity
X-stale
The network request API in the Admin UI is not particularly intuitive and is not scaling well. An overview of current issues:
CachedDataReducer
APICachedDataReducer has an unintuitive API for refreshing data: React components that need routinely-refreshed data (e.g. refresh some data every 10 seconds) must dispatch a "refresh" thunk action inside of both
componentDidUpdate
andcomponentWillReceiveProps
. The intention is that periodically fetched data will only be fetched only if there is a currently rendered component which needs it. However, this strategy is often unclear to new developers, requires a hack to work correctly (requiring thevalid
flag to be a connected property), is difficult to debug, and is providing confusion in use cases which do not require data to be periodically refreshed.Additionally, the use of CachedDataReducer as a "reducer factory", while reducing boilerplate, does seem to introduce some conceptual complexity; it is also only one possible solution to re-using the cached data pattern across multiple endpoints. We might investigate the use of type-safe accessors (the pattern currently used for local settings) instead of directly typing the repository.
Project Organization
Currently, the endpoint definitions for our API are under
/util/api.ts
, while the actual cached data reducers are defined under/redux/apiReducers
. Things are basically all over the place; even if we don't change the underlying pattern much, we should reorganize this structure to be more straightforward.The text was updated successfully, but these errors were encountered: