Elm app navigation moved into the model, with the URL reduced to a thin wrapper
A developer describes an alternative way to handle navigation in Elm applications, where the model rather than the URL determines the current screen. In the conventional approach, update writes the URL and the app only changes page when UrlChanged returns, which the author found led to scattered navigation logic, duplicate update cycles, and temporary mismatches between model and URL. Under the new design, the model stores the app's destination, and a wrapper around the root update syncs the URL from that destination after each step. The URL is only parsed into a move at startup, on back and forward actions, and when links are clicked. The author provides three sample blog implementations in a public repository for comparison.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in