Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building highly resilient web apps with Elm

Jon Kelly
February 24, 2017

Building highly resilient web apps with Elm

A review of using Elm for building highly resilient web apps plus a comparison with Angular2/RxJs

Jon Kelly

February 24, 2017
Tweet

More Decks by Jon Kelly

Other Decks in Technology

Transcript

  1. What’s different with Elm All the jargon you may have

    heard (and more)  Immutability  Pure functions  Compiled code  Uni-directional data flow (any redux fans here?) btw, it runs pretty fast
  2. FP background  Immutability - not always so fixed 

    Compiled code - not all languages, e.g. Lisp
  3. Elm has real benefits This UI is straightforward to code

    and reason about Basic framework – 20 lines of code
  4. Overview Elm code basics Elm front-end DEMO! Time travel debugging

    Elm - uni-directional design Bonus - solutions in Angular2/RxJs app (if we get the time)
  5. Elm code - currying timesTwice x y = two *

    x * y timesTwice 3 4 = 24 x = timesTwice 3 = ?? x 4 = 24
  6. Types The usual num/int, float, string, bool Suspects Lists like

    arrays Any length – can only store a single type Tuples like, er, multiples ? Fixed length – may store multiple types Records a bit object-y and a bit duck type-y
  7. Lists - real quick Build [1,2,3] like this 1:: 2

    :: 3 :: [] Pass as params : xs – entire list x:xs (destructuring like ES6) x is “head”, xs is “tail” NOTE - access anything after head – takes longer TL;DR – Elm functions designed to work with head of list as much as possible
  8. Elm code - tuples timesTwice (x, y) = two *

    x * y timesTwice (3, 4) = 24 anotherTwice (x, y) = (x * two, y * two) anotherTwice (5,7) = (10, 14)