Skip to content

Commit a326d58

Browse files
committed
update subscriptions parameter in elmish.mount for clarity fixe #57
1 parent 0fd18b2 commit a326d58

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ function update (action, model) { // Update function takes the current state
1515
}
1616

1717
function view(model, signal) {
18-
return div(['id=wrap'], [
18+
return div([], [
1919
button(["class=inc", "id=inc", signal('inc')], [text('+')]), // increment
2020
div(["class=count", "id=count"], [text(model.toString())]), // count
2121
button(["class=dec", "id=dec", signal('dec')], [text('-')]), // decrement
2222
button(["class=reset", "id=reset", signal('reset')], [text('Reset')])
2323
]);
2424
}
2525

26-
function subscriptions (signal, root) {
26+
function subscriptions (signal) {
2727
var UP_KEY = 38; // increment the counter when [↑] (up) key is pressed
2828
var DOWN_KEY = 40; // decrement the counter when [↓] (down) key is pressed
2929

Diff for: examples/counter-reset-keyboard/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
mount(0, update, view, 'app', subscriptions);
2121
console.log('subs:', subscriptions.toString());
2222
</script>
23-
24-
23+
2524
</body>
2625
</html>

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ function empty (node) {
1919
* @param {Function} update how the application state is updated ("controller")
2020
* @param {Function} view function that renders HTML/DOM elements with model.
2121
* @param {String} root_element_id root DOM element in which the app is mounted
22-
* @param {Function} subs any event listeners the application needs
22+
* @param {Function} subscriptions any event listeners the application needs
2323
*/
24-
function mount (model, update, view, root_element_id, subs) {
24+
function mount (model, update, view, root_element_id, subscriptions) {
2525
var ROOT = document.getElementById(root_element_id); // root DOM element
2626
var store_name = 'elmish_' + root_element_id; // test-app !== app
2727

@@ -41,7 +41,9 @@ function mount (model, update, view, root_element_id, subs) {
4141

4242
model = JSON.parse(localStorage.getItem(store_name)) || model;
4343
render(model, signal, ROOT);
44-
if (subs && typeof subs === 'function') { subs(signal, ROOT); }
44+
if (subscriptions && typeof subscriptions === 'function') {
45+
subscriptions(signal);
46+
}
4547
}
4648

4749
/**

0 commit comments

Comments
 (0)