Created
April 17, 2017 15:59
-
-
Save chrisza4/dc845cfb3c1ebfca8fe7d7b930ab57f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns todomvc.state | |
| (:require [reagent.core :as r] | |
| [cljs-uuid-utils.core :as uuid])) | |
| (defonce todo-data (r/atom (array-map))) | |
| (defn add [title] | |
| (let [new-uuid (uuid/uuid-string (uuid/make-random-uuid))] | |
| (swap! todo-data assoc new-uuid {:id new-uuid | |
| :title title | |
| :completed false | |
| :editing false}))) | |
| (defn toggle [id] | |
| (swap! todo-data update-in [id :completed] not)) | |
| (defn delete [id] | |
| (swap! todo-data dissoc id)) | |
| (defn toggle-edit [id] | |
| (swap! todo-data update-in [id :editing] not)) | |
| (defn edit [id title] | |
| (swap! todo-data assoc-in [id :title] title)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment