This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 2.0.0
Elm PageLoader utility
version 2.0.1
license MIT
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 2.0.1
Committed At 2017-12-18 16:39:27 UTC
krisajenkins/remotedata 4.3.1 <= v < 5.0.0 4.5.0
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1

README

Elm PageLoader

Utility library for SPA pages that have dependencies/

The idea

The pages in a SPA can have dependencies resolved before the pages makes any sense. With dependencies i mean api requests or any kind of command that you need answered like getting a random number. If your page has dependencies than you can either move to the new page and work with Maybe's in your model. Or handle the dependencies before transitioning to the new page.

I personally do not like testing for Maybe's all the time, and neither do i like blank places that gets filled in over time.

If you want to go for the handle the dependencies before transitioning method, then you do not need to worry about Maybe's in your page. You know that you have the data because it is already given to you before you transitioned to your new page. That will keep your pages code cleaner and easier to argue about.

If you only have one dependency that you could send a command to resolve that dependency. And when it comes back as a message then you set your page as the new page with the resolved dependency data.

That works pretty easy but it gets a bit harder when you have multiple dependencies. Then you have to track all those dependencies before you can switch pages. You can argue that all the data should be resolved in one api request. But sometimes you might need something from the api and something from the elm program like the time. Or from two different api's. It is all possible. And with http/2 and service workers splitting my api requests into more specific requests can be lucrative.

Handling based on the status of the dependencies is where this library comes in. Hopefully it helps you setup a clean way of managing your dependencies and transitions between pages.

A demo site implementing this library can be found in the demo site repository.

A description about the types and functions can be found on package.elm-lang.org.

Basic concepts

Coming soon. Please see the demo's source code for now..