From 4c0017592cf18a4210b7d4adda71043dcab552c1 Mon Sep 17 00:00:00 2001 From: Mathieu Larocque Date: Wed, 18 Jan 2017 18:12:39 -0500 Subject: [PATCH 1/4] modifs --- examples/Gobblers | 1 + examples/todos/src/model.js | 14 ++++ examples/todos/src/view/App.js | 2 + .../todos/src/view/components/Coloring.js | 11 +++ examples/todos/src/view/components/Todo.js | 57 ++++++++++--- .../src/view/containers/VisibleTodoList.js | 6 +- modelux.js | 84 +++++++++++++------ 7 files changed, 136 insertions(+), 39 deletions(-) create mode 160000 examples/Gobblers create mode 100644 examples/todos/src/view/components/Coloring.js diff --git a/examples/Gobblers b/examples/Gobblers new file mode 160000 index 0000000..a38ad41 --- /dev/null +++ b/examples/Gobblers @@ -0,0 +1 @@ +Subproject commit a38ad412f81eacf6c7b53980b10594c422da8086 diff --git a/examples/todos/src/model.js b/examples/todos/src/model.js index a766ff0..9cc2221 100644 --- a/examples/todos/src/model.js +++ b/examples/todos/src/model.js @@ -11,6 +11,9 @@ export default createController({ }; return this.getState().concat(todo); }, + remove: function (id) { + return this.getState().filter(todo => todo.id !== id); + }, toggle: function(todoId) { return this.getState().map(todo => { if (todo.id === todoId) { @@ -25,5 +28,16 @@ export default createController({ set: function(newFilter) { return newFilter; } + }, + color: { + initial: 'red', + toggle: function () { + var s = this.getState(); + if (s === 'red') { + return 'green' + } else { + return 'red' + } + } } }); diff --git a/examples/todos/src/view/App.js b/examples/todos/src/view/App.js index 94ac682..45eb066 100644 --- a/examples/todos/src/view/App.js +++ b/examples/todos/src/view/App.js @@ -1,5 +1,6 @@ import React from 'react' import Footer from './components/Footer' +import Coloring from './components/Coloring' import AddTodo from './containers/AddTodo' import VisibleTodoList from './containers/VisibleTodoList' @@ -8,6 +9,7 @@ const App = () => (