Skip to content

Instantly share code, notes, and snippets.

@markhamburg
markhamburg / IdentityContinuity.elm
Created October 17, 2016 20:25
A demonstration of how to achieve identity continuity using Html.Keyed in Elm
import Html exposing (div, input, text, fieldset, label)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onInput, onClick)
import Html.Attributes exposing (value, type', style, name)
import Html.Keyed
type alias Model =
{ text : String
, items : List String
@markhamburg
markhamburg / InputDemo.elm
Created September 25, 2016 19:16
A demonstration of how text fields need identity continuity
import Html exposing (div, input, text, fieldset, label)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onInput, onClick)
import Html.Attributes exposing (value, type', style, name)
type alias Model =
{ text : String
, items : List String
, position : BeforeAfter
@markhamburg
markhamburg / CounterWithStack4.elm
Created September 10, 2016 22:19
Move the private state into a dictionary. I feel like I'm starting to re-invent elm-parts/elm-mdl.
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App
import Html.Events exposing (..)
import Dict
type CounterMsg
= Decrement
@markhamburg
markhamburg / CounterWithStack3.elm
Created September 10, 2016 21:49
This version handles the communication back to the global state by using message generation.
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App
import Html.Events exposing (..)
type CounterMsg
= Decrement
| Increment
@markhamburg
markhamburg / CounterWithStack2.elm
Created September 9, 2016 21:23
Another version of the counter with stack example for private state, this time with a utility to encapsulate the repeated update logic.
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App
import Html.Events exposing (..)
type CounterMsg
= Decrement
| Increment
@markhamburg
markhamburg / CounterWithStack.elm
Created September 9, 2016 19:51
An example of an Elm view with both shared and private state — in this case a counter with an integer shared state and a private stack of values.
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.App
import Html.Events exposing (..)
type CounterMsg
= Decrement
| Increment