diff --git a/README.md b/README.md index faa2959b..1ed6464c 100644 --- a/README.md +++ b/README.md @@ -443,6 +443,13 @@ Watch the UI tests go red in the browser: #### 9.6 Make UI Tests Pass (_writing the minimum code_) +Luckily _both_ these tests only requires a _single_ line of code to make pass! + +```js +button('Reset', signal, Res) +``` +![reset-counter](https://cloud.githubusercontent.com/assets/194400/25822128/82eb7a8e-342f-11e7-9cd0-1a69d95ee878.gif) +

diff --git a/examples/counter-reset/counter.js b/examples/counter-reset/counter.js index 494a9f25..fde53f53 100644 --- a/examples/counter-reset/counter.js +++ b/examples/counter-reset/counter.js @@ -31,12 +31,13 @@ function view(signal, model, root) { empty(root); // clear root element before return [ // Store DOM nodes in an array button('+', signal, Inc), // then iterate to append them - div('count', model), // avoids repetition. + div('count', model), // create div with stat as text button('-', signal, Dec), // decrement counter button('Reset', signal, Res) // reset counter ].forEach(function(el){ root.appendChild(el) }); // forEach is ES5 so IE9+ } // yes, for loop is "faster" than forEach, but readability trumps "perf" here! + // The following are "Helper" Functions which each "Do ONLY One Thing" and are // used in the "View" function to render the Model (State) to the Browser DOM: