Hi,
I’m trying to achieve something that should be pretty simple (on the face of it), but it has highlighted my lack of knowledge of the view-update loop in respect to DOM re-draws, and so was hoping someone could enlighten me.
(I may also be suffering from a mind-blockage and simply missing the 'bleedin obvious`
)
My Scenario
I am retrieving a heap of data from my server that takes a few seconds to be processed by Elm when it is received. I therefore want to provide information to the user of the current state - Loading then Processing then Ready.
My Problem
When the data is received, I can switch the state on the model from Loading to Processing, and begin processing the data, but the update to the model state is not reflected in the view until the processing is complete. This I understand and expected.
Solutions?
I guess I need to trigger a re-draw of the DOM? I thought the following might suffice:
- When the data is received in
update:
a. update the model state:{ model | state = Processing }
b. start aTask:Task.perform TimeMsg Time.now - When
TimeMsgis received inupdatestart processing the data
I figured the view would be updated between steps 1 and 2 and reflect the new model, but it appears that it isn’t.
I could try various other Tasks, and maybe try ports to force the view-update loop to be triggered with the updated model, but I feel that I don’t really understand the cycle, and although I might find a solution I would prefer to understand it rather than simply find it by experimenting and maybe end up with the wrong assumptions.
Also, using a built-in Task or a port loop feels a bit hacky, and doesn’t really express that all I want to do is to update the view prior to starting to process the data received in update.
Can someone explain further or point me to some reading? I would like to understand more about what is going on under the hood. (Do some Tasks, but not others, cause the view-update loop to be initiated with the updated model, if so, how do you determine which ones? Is there a way to create a custom Task that expresses better what I want to achieve - assuming this forces a DOM re-draw.)
TIA to anyone that can explain further.

)