Skip to content

Commit

Permalink
Fix TodoMVC sample
Browse files Browse the repository at this point in the history
  • Loading branch information
wakwak3125 committed Jan 2, 2018
1 parent f0cab99 commit a5626a8
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public class TodoListReducer {
@Dispatchable(AddTodoAction.class)
public TodoList onAddedTodo(TodoList state, AddTodoAction action) {
List<TodoList.Todo> list = state.getTodoList();
if (list.isEmpty()) {
list.add(new TodoList.Todo(0, action.getText()));
return new TodoList(list);
}
int id = Observable.fromIterable(list)
.reduce((todo, todo2) -> (todo.getId() < todo2.getId()) ? todo2 : todo)
.onErrorReturn(throwable -> new TodoList.Todo(0, ""))
.toObservable()
.blockingLast()
.blockingGet()
.getId();
list.add(new TodoList.Todo(id + 1, action.getText()));
return new TodoList(list);
Expand Down

0 comments on commit a5626a8

Please sign in to comment.