API Model Helpers
For many resources in the model (e.g. servers), we track the loading status. When we make an API request for one of these resources, we must update the model to reflect that we are loading it. Previously, we would do these as two separate, de-coupled actions.
I think these actions should generally be coupled -- we should reach for one function which both fires the Cmd
to request the resource, and sets it as loading in the model. I think this will produce cleaner high-level code and less opportunity for mistakes. This MR attempts to do that with Rest.ApiModelHelpers
. The requestServers
function both makes the request and updates the model to show it is loading.
I am also trying out a pipelineCmd
function, which makes it easy to pipeline functions which expect a Model
and return a (Model, Cmd Msg)
. For example, the following pipeline makes three API requests and sets the resource status to loading for each!
( model, cmd )
|> Helpers.pipelineCmd (ApiModelHelpers.requestNetworks project.auth.project.uuid)
|> Helpers.pipelineCmd (ApiModelHelpers.requestComputeQuota project.auth.project.uuid)
|> Helpers.pipelineCmd (ApiModelHelpers.requestVolumeQuota project.auth.project.uuid)
This is sort of related to #427 (closed).
To do
-
What to do aboutSee #431.Orchestration
module, which generally deals inProject
s rather than the entireModel
?
How to Test
(Please describe how to exercise these changes in the application)
Screenshots
(If visual changes are introduced, show what they look like)