With the release of Elm 0.18 the official libraries Navigation
and UrlParser
have become a lot more robust and useful. They now integrate a lot of the functionality that Hop used to provide for previous versions of Elm. For example UrlParser
now has parseHash
and parsePath
. Because of this I'm not convinced that Hop needs to be upgraded to Elm 0.18. I'll wait and see if this library could provide value in 0.18.
Hop is a helper library meant to be used with:
- Navigation v1 for listening to location changes in the browser and pushing changes to it.
- UrlParser v1 for constructing routes and parsing URLs.
On top of these two packages above, Hop helps with:
- Abstracting the differences between push or hash routing
- Providing helpers for working with the query string
- Encode / Decode the location path
- Encode / Decode the query string
Please see this example app. It explains how to wire everything in the comments.
A proper url should have the query before the hash e.g. ?keyword=Ja#/users/1
,
but when using hash routing, query parameters are appended after the hash path e.g. #/users/1?keyword=Ja
.
This is done for aesthetics and so the router is fully controlled by the hash fragment.
See examples/basic
and examples/full
folders. To run the example apps:
- Clone this repo
- Go to example folder
- Follow the readme in that folder