Skip to content

Instantly share code, notes, and snippets.

@goatslacker
Created August 20, 2015 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goatslacker/3ab97b367d877087c687 to your computer and use it in GitHub Desktop.
Save goatslacker/3ab97b367d877087c687 to your computer and use it in GitHub Desktop.
Actions that depend on other actions
class TodoStore {
createdTodo(todo) {
this.todos.push(todo)
}
save() {
...
}
}
class TodoView extends React.Component {
onCreateTodo() {
TodoActions.createdTodo('Write the tests')
}
componentDidUpdate() {
TodoActions.saveAllTodos()
}
render() {
return this.todos.map(todo => <Todo todo={todo} />)
}
}
class TodoStore {
createdTodo(todo) {
this.todos.push(todo)
this.save()
}
save() {
...
}
}
class TodoView extends React.Component {
onCreateTodo() {
TodoActions.createdTodo('Write the tests')
}
render() {
return this.todos.map(todo => <Todo todo={todo} />)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment