The doubt I have is I don’t know why the view is not properly refreshed after adding the pattern matching for choosing which div that should be shown:
view : Model -> Html Msg
view model =
let
otherDiv : Html Msg
otherDiv = case model.current of
Change t -> div [name "Processed div"] [ text (String.reverse t)]
_ -> div [name "Default div"] []
in
div []
[
input [ placeholder "Text to reverse", value model.content, onInput Change ] []
, otherDiv
]
On the presented case, it shows the default div and, after adding some text to the input, the div swap does not happen. Thus the reversed text is not shown. Why? How can I make it work?
This is a blueprint of what is happening on my code, where I choose which portion of html should be viewed depending on the last message. When the a message is produced I update the model.
Can you provide more information on why do you think you need the last message in the view?
The way things usually work is that the view generates messages, the messages update the model and the view gets updated with the new data from the model. There is no need for the view to know which was the last message.
Here is how I interpret the code you posted: https://ellie-app.com/9tzrJgRsRRca1
What is wrong with this interpretation with respect to what you are trying to achieve?
Sorry for no replying before. I detected the problem. I think I was duplicating the model, calling one function with the model and the other, the view with the pattern matching, with another modified model. Rookie mistake.