Cache project query result
Databinding can trigger several queries very quickly, which in a slower connection could cause bad UX so we could add a caching mechanism to the project retrieval logic. This cache would be refreshed whenever the user clicks on the Refresh button or when we explicitly want to trigger it.
Just to be sure, the project selector itself is independent of databinding (like the current AccountSelector), right? It's the deploy preferences that will want to wire up databinding, right?
Currently the project selector depends on another class to provide the list of projects like a repository, and the caching could be added to this repository. But the project selector is not even in PR so things may change.
Another question: if we hadn't used databinding, can we avoid introducing this caching? Or, will this caching still be desired even in the absent of databiniding?
I haven't investigated it as currently databinding saves us from writing a lot of code.
The two calls to projectRepository.getProjects():
- when databinding is added to the account selector, the selection change listener triggers the project list query corresponding to the account selected
- to display validation errors when we open the dialog, we call
DataBindingContext.updateTargets()which while triggers the validation and in case of error the error message to be displayed, but also triggers the querying of the project list.
We may be able to avoid the second query if the account selector only fires the selection changed event if there's a change to the selection.