No description
Find a file
2016-11-10 08:49:21 +02:00
.gitignore Initial 2016-11-09 20:26:57 +02:00
BMI.elm Destructure 2016-11-10 08:49:21 +02:00
Counter.elm BMI example 2016-11-09 21:40:17 +02:00
Dom.elm Cleaned 2016-11-10 08:42:46 +02:00
Elems.elm Cleaned 2016-11-10 08:42:46 +02:00
ElemsWithAdd.elm More explicit 2016-11-10 08:25:56 +02:00
elm-package.json Initial 2016-11-09 20:26:57 +02:00
Lens.elm Cleaned 2016-11-10 08:42:46 +02:00
Main.elm Cleaned 2016-11-10 08:42:46 +02:00
README.md Edit 2016-11-09 22:41:24 +02:00
Removable.elm Initial 2016-11-09 20:26:57 +02:00
Slider.elm BMI example 2016-11-09 21:40:17 +02:00

Quickstart

git clone https://github.com/polytypic/elm-reactive-dom-with-lensed-state-toy.git
cd elm-reactive-dom-with-lensed-state-toy.git
elm-reactor
open http://localhost:8000/Main.elm

WTF?

This is a toy example meant to illustrate how one can create composable components using reactive dom and lensed state. This is absolutely not a serious implementation of the approach.

In the Elm architecture every component consists of several parts such as model, view, update, subscriptions and init. When you create components that use other components, you need to manually compose each of those parts separately. You need to write a view function that calls the view functions of child components and an update function that similarly calls the update functions of child components and so on. This means that one needs to write quite a bit of boilerplate code to "compose" components. Indeed, Elm components are only composable by brute-force.

Now, with the approach illustrated in this repository, each component essentially consists only of a single function.

Instead of returning just VDOM, the single function returns "reactive" VDOM that can automatically update when the underlying state changes.

State is represented in the form of reactive variables that can be read and written and embedded into the reactive VDOM. Component functions can take any number of reactive variables as parameters.

This way most of the boilerplate required in the Elm architecture simply vanishes.

Now, this is a toy implementation only meant to illustrate the way components roughly look like with this approach. Instead of using reactive variables, this example simply uses lenses. There are several more serious implementations of this basic approach in various languages, including JavaScript and F#, that have actually been used in production to write non-trivial applications. This shit works.