Closed egoist closed 6 years ago
const Todo = zerotwo({ state: { text: null, completed: false, id: null }, actions: self => ({ complete: () => self.completed = !self.completed, remove: () => self.getParent().removeTodo(self) }) }) const Todos = zerotwo({ state: { todos: [] }, actions: self => ({ addTodo: text => self.todos.push(Todo({ text, id: Date.now() })), removeTodo: todo => self.todos = self.todos.filter(t => t.id !== todo.id) }) })