<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base data-ice="baseUrl" href="../../../../../">
  <title data-ice="title">src/routes/Todo/reducers/todos.js | API Document</title>
  <link type="text/css" rel="stylesheet" href="css/style.css">
  <link type="text/css" rel="stylesheet" href="css/prettify-tomorrow.css">
  <script src="script/prettify/prettify.js"></script>
  
  
  <script src="script/manual.js"></script>
</head>
<body class="layout-container" data-ice="rootContainer">

<header>
  <a href="./">Home</a>
  
  <a href="identifiers.html">Reference</a>
  <a href="source.html">Source</a>
  
  
  <div class="search-box">
  <span>
    <img src="./image/search.png">
    <span class="search-input-edge"></span><input class="search-input"><span class="search-input-edge"></span>
  </span>
    <ul class="search-result"></ul>
  </div>
</header>

<nav class="navigation" data-ice="nav"><div>
  <ul>
    
  <li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">actions</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-setLocaleToEnglish">setLocaleToEnglish</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-setLocaleToFrench">setLocaleToFrench</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">components</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/App.js~App.html">App</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/GlobalNav.js~GlobalNav.html">GlobalNav</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/Loading.js~Loading.html">Loading</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/NotFound.js~NotFound.html">NotFound</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/components/Welcome.js~Welcome.html">Welcome</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Comments</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Comments/index.js~Comments.html">Comments</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Comments/actions</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-addComment">addComment</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Comments/components</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Comments/components/Comment.js~CommentBox.html">CommentBox</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Comments/components/CommentList.js~CommentList.html">CommentList</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Comments/reducers</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-comments">comments</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Todo</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Todo/index.js~Todo.html">Todo</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Todo/actions</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-addTodo">addTodo</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-setVisibilityFilter">setVisibilityFilter</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-toggleTodo">toggleTodo</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Todo/components</div><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Todo/components/Footer.js~Footer.html">Footer</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Todo/components/Link.js~Link.html">Link</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Todo/components/Todo.js~Todo.html">Todo</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-class">C</span><span data-ice="name"><span><a href="class/src/routes/Todo/components/TodoList.js~TodoList.html">TodoList</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Todo/containers</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-AddTodo">AddTodo</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-FilterLink">FilterLink</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-VisibleTodoList">VisibleTodoList</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">routes/Todo/reducers</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-todoApp">todoApp</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-todos">todos</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-visibilityFilter">visibilityFilter</a></span></span></li>
<li data-ice="doc"><div data-ice="dirPath" class="nav-dir-path">store</div><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-createAndConfigStore">createAndConfigStore</a></span></span></li>
<li data-ice="doc"><span data-ice="kind" class="kind-variable">V</span><span data-ice="name"><span><a href="variable/index.html#static-variable-injectAsyncReducer">injectAsyncReducer</a></span></span></li>
</ul>
</div>
</nav>

<div class="content" data-ice="content"><h1 data-ice="title">src/routes/Todo/reducers/todos.js</h1>
<pre class="source-code line-number raw-source-code"><code class="prettyprint linenums" data-ice="content">const todo = (state, action) =&gt; {
  switch (action.type) {
    case &apos;ADD_TODO&apos;:
      return {
        id: action.id,
        text: action.text,
        completed: false
      }
    case &apos;TOGGLE_TODO&apos;:
      if (state.id !== action.id) {
        return state
      }

      return Object.assign({}, state, {
        completed: !state.completed
      })

    default:
      return state
  }
}

const todos = (state = [], action) =&gt; {
  switch (action.type) {
    case &apos;ADD_TODO&apos;:
      return [
        ...state,
        todo(undefined, action)
      ]
    case &apos;TOGGLE_TODO&apos;:
      return state.map(t =&gt;
        todo(t, action)
      )
    default:
      return state
  }
}

export default todos
</code></pre>

</div>

<footer class="footer">
  Generated by <a href="https://esdoc.org">ESDoc<span data-ice="esdocVersion">(0.4.6)</span></a>
</footer>

<script src="script/search_index.js"></script>
<script src="script/search.js"></script>
<script src="script/pretty-print.js"></script>
<script src="script/inherited-summary.js"></script>
<script src="script/test-summary.js"></script>
<script src="script/inner-link.js"></script>
<script src="script/patch-for-local.js"></script>
</body>
</html>
