
TL;DR
In the previous post, we learned how to add Elm View to our Picshare application. This post is part of the functional language series, and it is based on a remarkable book, Programming Elm Build Safe and Maintainable Front-End Applications by Jeremy Fairbank.
Update Model
If you observe the current implementation of our Picshare application, you can see that model state flows top-down from main to view to viewDetailedPhoto.
To update the application model state, we need to implement an update function that takes two parameters, message and model. The message describes the event from the application environment (server-side, web-socket, or mouse-click), and application logic does something on the current state model, and the result is a new state model. Let’s prepare everything needed for update function.
Here is the gist:
Compile and open idex.html and you will get like button that does nothing.
elm make src/Picshare.elm --output picshare.js
open index.html

Comments are closed.