School project used in master's degree thesis. Purpose of this project is to enable elegant page composition in single page applications in Elm. Using this package in SPA, one should get rid of all the unnecessary boilerplate code in main module that serves just the puspose of composing various pages.
Everything needed for page composition is in src folder, in Alt module. Alt module consists of helper types, functions for composition, router, url parsing and header and footer, e.g. everything needed to build SPA.
To use in elm project just install the package:
elm install adamstuller/elm-spa-compositionAfter install import PageWidget type from Alt module in every page module. This page widget, containg all the main functions should be the only think (along with parser if needed) exposed from module.
In Main.elm just import all page widgets and join them using join and add functions. In the end add router using initRouter function.
Simpliest example can be found in this repository in example folder. There one can find various pages using different concepts an also the main module.
Another example is simple SPA called tabor bizon, created as byproduct of master's thesis located on github https://github.com/adamstuller/taborbizon. There you can see difference between braches main which is still written without our example and branch rewrite which is written using this package.
In this repository code in main module looks like this:
main =
Home.initPage topParser
|> join (Form.initPage <| basicParser "form")
|> initRouter "Tábor bizón" viewHeader viewFooter
|> Browser.applicationJust two pages cleanly connected using one function without any boilerplate code.
Yet another example is Realworld application written by Richard Feldman. This application is also on github - https://github.com/rtfeldman/elm-spa-example. We refactored this application as well and result can be seen on our forked repository: https://github.com/adamstuller/elm-spa-example. Here on branch master is old Feldman's code and on brach rewrite is ours.