Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @AutoReducer
- public abstract class TodoReducer implements Reducer<List<TodoItem>> {
- @AutoReducer.Action(TodoActions.ADD_ITEM)
- List<TodoItem> addItem(List<TodoItem> items, TodoItem item) {
- return TreePVector.from(items)
- .plus(item);
- }
- @AutoReducer.Action(TodoActions.CHANGE_STATE)
- List<TodoItem> changeState(List<TodoItem> items, long id, boolean isChecked) {
- for (int i = 0; i < items.size(); i++) {
- TodoItem todoItem = items.get(i);
- if (todoItem.id == id) {
- TodoItem changed = new TodoItem(id, todoItem.text, isChecked);
- return TreePVector.from(items)
- .with(i, changed);
- }
- }
- return items;
- }
- public static TodoReducer create() {
- return new TodoReducerImpl();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement