import { createElement as h } from 'react';

export const main = {
  init: init(),
  update,
  view
};


// MODEL
function init() {
  return 0;
}


// MSG
function Increment() {}
function Decrement() {}


// UPDATE
function update(msg, model) {
  switch(msg.constructor) {
    case Increment:
      return model + 1;
    case Decrement:
      return model - 1;
  }
}


// VIEW
function view(d) {
  return model =>
    h('p', null,
      `Clicked: ${model} times`,
      h('button', { onClick: d(Increment) }, '+'),
      h('button', { onClick: d(Decrement) }, '-')
    );
}

@@ -414,17 +414,19 @@
 %0A    h('
-p
+div
 ', null,
@@ -430,41 +430,8 @@
 ll,%0A
-      %60Clicked: $%7Bmodel%7D times%60,%0A
     
@@ -457,18 +457,18 @@
 lick: d(
-In
+De
 crement)
@@ -476,13 +476,42 @@
 %7D, '
-+
+-
 '),%0A
+      h('div', null, model),%0A
     
@@ -529,34 +529,34 @@
 ', %7B onClick: d(
-De
+In
 crement) %7D, '-')
@@ -552,17 +552,17 @@
 nt) %7D, '
--
++
 ')%0A    )

Refactor counter example