From 8abb75b95da4e1608b036fd4342a98a0a6cf2fae Mon Sep 17 00:00:00 2001 From: Dan Holmsand Date: Fri, 31 Jul 2015 09:32:17 +0200 Subject: [PATCH] atom -> r/atom in examples --- demo/reagentdemo/syntax.cljs | 4 +++- examples/simple/src/simpleexample/core.cljs | 10 +++++----- examples/todomvc/src/todomvc/core.cljs | 18 +++++++++--------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/demo/reagentdemo/syntax.cljs b/demo/reagentdemo/syntax.cljs index 15090b7..6d9d149 100644 --- a/demo/reagentdemo/syntax.cljs +++ b/demo/reagentdemo/syntax.cljs @@ -55,7 +55,8 @@ (string/join ")|(" [comment-p str-p open-p close-p meta-p iden-p any-p]) ")")) - keyw-re #"^:"] + keyw-re #"^:" + qualif-re #"^r/"] (for [[s comment str-litt open close met iden any] (re-seq patt src)] (cond comment [:comment s] @@ -66,6 +67,7 @@ iden (cond (re-find keyw-re s) [:keyw s] (builtins s) [:builtin s] + (re-find qualif-re s) [:builtin s] :else [:iden s]) any [:other s])))) diff --git a/examples/simple/src/simpleexample/core.cljs b/examples/simple/src/simpleexample/core.cljs index 103b059..f90333c 100644 --- a/examples/simple/src/simpleexample/core.cljs +++ b/examples/simple/src/simpleexample/core.cljs @@ -1,9 +1,9 @@ (ns simpleexample.core - (:require [reagent.core :as reagent :refer [atom]])) + (:require [reagent.core :as r])) -(defonce timer (atom (js/Date.))) +(defonce timer (r/atom (js/Date.))) -(defonce time-color (atom "#f34")) +(defonce time-color (r/atom "#f34")) (defonce time-updater (js/setInterval #(reset! timer (js/Date.)) 1000)) @@ -31,5 +31,5 @@ [color-input]]) (defn ^:export run [] - (reagent/render [simple-example] - (js/document.getElementById "app"))) + (r/render [simple-example] + (js/document.getElementById "app"))) diff --git a/examples/todomvc/src/todomvc/core.cljs b/examples/todomvc/src/todomvc/core.cljs index 1e15b71..83a3db9 100644 --- a/examples/todomvc/src/todomvc/core.cljs +++ b/examples/todomvc/src/todomvc/core.cljs @@ -1,9 +1,9 @@ (ns todomvc.core - (:require [reagent.core :as reagent :refer [atom]])) + (:require [reagent.core :as r])) -(defonce todos (atom (sorted-map))) +(defonce todos (r/atom (sorted-map))) -(defonce counter (atom 0)) +(defonce counter (r/atom 0)) (defn add-todo [text] (let [id (swap! counter inc)] @@ -25,7 +25,7 @@ (complete-all true))) (defn todo-input [{:keys [title on-save on-stop]}] - (let [val (atom title) + (let [val (r/atom title) stop #(do (reset! val "") (if on-stop (on-stop))) save #(let [v (-> @val str clojure.string/trim)] @@ -41,7 +41,7 @@ nil)})]))) (def todo-edit (with-meta todo-input - {:component-did-mount #(.focus (reagent/dom-node %))})) + {:component-did-mount #(.focus (r/dom-node %))})) (defn todo-stats [{:keys [filt active done]}] (let [props-for (fn [name] @@ -59,7 +59,7 @@ "Clear completed " done])])) (defn todo-item [] - (let [editing (atom false)] + (let [editing (r/atom false)] (fn [{:keys [id done title]}] [:li {:class (str (if done "completed ") (if @editing "editing"))} @@ -74,7 +74,7 @@ :on-stop #(reset! editing false)}])]))) (defn todo-app [props] - (let [filt (atom :all)] + (let [filt (r/atom :all)] (fn [] (let [items (vals @todos) done (->> items (filter :done) count) @@ -104,5 +104,5 @@ [:p "Double-click to edit a todo"]]])))) (defn ^:export run [] - (reagent/render [todo-app] - (js/document.getElementById "app"))) + (r/render [todo-app] + (js/document.getElementById "app")))