Skip to content

Instantly share code, notes, and snippets.

@vitalipe
Last active June 15, 2017 11:27
Show Gist options
  • Select an option

  • Save vitalipe/2e1e8c7d3df3877b2cfc4e6a7afe796e to your computer and use it in GitHub Desktop.

Select an option

Save vitalipe/2e1e8c7d3df3877b2cfc4e6a7afe796e to your computer and use it in GitHub Desktop.
var state = mobx.observable({
todos : [],
visibilityFilter : "ALL",
addTodoItem : action(function (text, completed) {
this.todos.push({text, completed})
}),
setVisibilityFilter : action(function (filter) {
this.visibilityFilter = filter;
})
});
(def state (r/atom {
:todos []
:visibility-filter :all}))
(defn add-todo-item [text completed]
(swap! state update-in [:todos] conj {:text text :completed completed}))
(defn set-visibility-filter [filter]
(swap! state assoc :visibility-filter filter))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment