Skip to content

Commit eeec661

Browse files
committed
use view & update from counter-reset example to test elmish.mount generic function for #44
1 parent 08723c9 commit eeec661

File tree

4 files changed

+32
-4222
lines changed

4 files changed

+32
-4222
lines changed

Diff for: examples/counter-reset/counter.js

-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ function view(signal, model, root) {
2020
button('-', signal, Dec), // decrement counter
2121
button('Reset', signal, Res) // reset counter
2222
].forEach(function(el){ root.appendChild(el) }); // forEach is ES5 so IE9+
23-
console.log(">> root.childElementCount:", root.childElementCount);
2423
} // yes, for loop is "faster" than forEach, but readability trumps "perf" here!
2524

2625
// Mount Function receives all MUV and mounts the app in the "root" DOM Element
2726
function mount(model, update, view, root_element_id) {
28-
console.log('>> root_element_id:', root_element_id)
2927
var root = document.getElementById(root_element_id); // root DOM element
30-
console.log('>> root:', root)
3128
function signal(action) { // signal function takes action
3229
return function callback() { // and returns callback
3330
model = update(model, action); // update model according to action

Diff for: examples/todo-list/elmish.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ function empty(node) {
1919
return true;
2020
}
2121

22-
// Mount Function receives all MUV and mounts the app in the "root" DOM Element
22+
/**
23+
* `mount` mounts the app in the "root" DOM Element.
24+
* @param {Object} model store of the application's state.
25+
* @param {Function} update how the application state is updated ("controller")
26+
* @param {Function} view function that renders HTML/DOM elements with model.
27+
* @param {String} root_element_id root DOM element in which the app is mounted
28+
* @return {Boolean} returns true once app has been mounted.
29+
*/
2330
function mount(model, update, view, root_element_id) {
2431
var root = document.getElementById(root_element_id); // root DOM element
2532
function signal(action) { // signal function takes action
@@ -30,6 +37,7 @@ function mount(model, update, view, root_element_id) {
3037
};
3138
};
3239
view(signal, model, root); // render initial model (once)
40+
return true;
3341
}
3442

3543
function init(doc){

0 commit comments

Comments
 (0)