Skip to content

Commit b992e12

Browse files
committed
Update Replicant example
1 parent 05cbbbb commit b992e12

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.adoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,11 +1463,11 @@ file for the client UI.
14631463
(defonce todos
14641464
(js/document.getElementById "todos"))
14651465
1466-
(defonce state (atom {}))
1466+
(defonce store (atom {}))
14671467
14681468
(defn update-todos []
14691469
(a/go (let [resp (<! (http/get "/todos"))]
1470-
(swap! state assoc :todos (-> resp :body :results)))))
1470+
(swap! store assoc :todos (-> resp :body :results)))))
14711471
14721472
(defn delete-todo [id]
14731473
(a/go (<! (delete (str "/todos/" id)))
@@ -1492,10 +1492,14 @@ file for the client UI.
14921492
[:a {:href "#" :on {:click #(delete-todo id)}} "delete"]])
14931493
[:li (create-todo-form)]])
14941494
1495-
(add-watch state ::render (fn [_ _ _ s] (r/render todos (todo-list s))))
1495+
(add-watch store ::render (fn [_ _ _ s] (r/render todos (todo-list s))))
14961496
(update-todos)
14971497
----
14981498

1499+
WARNING: In the above example, the '`click`' event is bound to a function.
1500+
This is not considered best practice for Replicant, but used in the
1501+
example code for the sake of brevity.
1502+
14991503
Here we reach the edge of Duct. This ClojureScript file is not specific
15001504
to our framework, but would be at home in any Clojure project.
15011505
Nevertheless, for the sake of completeness we'll provide some

0 commit comments

Comments
 (0)