Skip to content

Commit 7d20353

Browse files
committed
Minor tweaks
1 parent cf37fdf commit 7d20353

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

examples/todomvc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<head>
3-
<title>Sample App</title>
3+
<title>Redux TodoMVC</title>
44
</head>
55
<body>
66
<div class='todoapp' id='root'>

examples/todomvc/stores/todos.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ADD_TODO, DELETE_TODO, EDIT_TODO, MARK_TODO, MARK_ALL } from '../constants/ActionTypes';
22

33
const initialState = [{
4-
text: 'do something',
4+
text: 'Use Redux',
55
marked: false,
66
id: 0
77
}];
@@ -16,7 +16,9 @@ export default function todos(state = initialState, action) {
1616
}, ...state];
1717

1818
case DELETE_TODO:
19-
return state.filter(todo => todo.id !== action.id);
19+
return state.filter(todo =>
20+
todo.id !== action.id
21+
);
2022

2123
case EDIT_TODO:
2224
return state.map(todo =>
@@ -33,13 +35,11 @@ export default function todos(state = initialState, action) {
3335
);
3436

3537
case MARK_ALL:
36-
let nextState;
37-
if (state.filter(todo => todo.marked).length < state.length) {
38-
nextState = state.map(todo => ({ ...todo, marked: true }));
39-
} else {
40-
nextState = state.map(todo => ({ ...todo, marked: false }));
41-
}
42-
return nextState;
38+
const areAllMarked = state.every(todo => todo.marked);
39+
return state.map(todo => ({
40+
...todo,
41+
marked: !areAllMarked
42+
}));
4343

4444
default:
4545
return state;

0 commit comments

Comments
 (0)