I am new to Elm/Elmish/MVU. I am trying to to fetch some data after a button click. How can i update the progressbar while iterating the results?
Is there a way to create a dispatch event without any user interaction? My idea was to propagate the create a function that does the processing for the list head, and then sends the tail to Loading, but there seems to be no way to continue from there. The view is stuck as progressbar (value 1)
Elmish.Program.mkSimple (fun () -> MainView.init) MainView.update MainView.view ... let update (msg: Msg) (state: State) : State = match msg with | LoadData -> match state with | Start s -> ... let deviceList = Api.Load() deviceList |> Array.iteri (fun i device-> ( // How to increment the progress bar here? ... ) Loaded devices | Loading p -> Loading p | Loaded (data, getModel) -> Loaded (data, getModel) ... let rec view (state: State) (dispatch) = ... let rec view (state: State) (dispatch) = match state with | Start s -> StackPanel.create [ StackPanel.spacing 8.0 StackPanel.children [ TextBox.create [ TextBox.text "Start" ] Button.create [ Button.content "Load data from api" Button.onClick (fun _ -> dispatch (LoadData)) ] ] ] | Loading progress -> StackPanel.create [ StackPanel.spacing 8.0 StackPanel.children [ ProgressBar.create [ ProgressBar.minimum 0.0 ProgressBar.maximum 100.0 ProgressBar.value progress.PercentageDone ] ] ] ...