zwilias/elm-disco

Disconnected views exploration.


License
BSD-3-Clause
Install
elm-package install zwilias/elm-disco 1.0.0

Documentation

Elm Disconnected views explorations

view : View Store msg
view =
    with q.items <|
        \items ->
            List.map renderTodo items |> div []


renderTodo : String -> View Store msg
renderTodo item =
    with q.intro <|
        \intro ->
            div []
                [ text intro
                , text item
                ]

The idea is that views can be explicitly asked for some info, but can also ask for info themselves.

This works through queries that know how to extract some info from a store:

type alias Store =
    { todo : List String
    , otherThing : String
    }


q :
    { items : Query Store (List String)
    , intro : Query Store String
    }
q =
    { items = .todo >> List.reverse
    , intro = .otherThing
    }

The "secret" here is that the store is actually passed around, you just can't access it. Not directly. Tadaa.