From ae87fbe0e34b44a388c0d57234a647b0df11e418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=AE=87=20Yu=20Zhao?= Date: Wed, 31 May 2017 23:23:14 +0800 Subject: [PATCH 1/4] fix requires to use the strict method --- examples/simple/src/simple/core.cljs | 6 +++--- examples/todomvc/src/todomvc/views.cljs | 27 +++++++++++++------------ src/re_frame/interceptor.cljc | 12 +++++------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/examples/simple/src/simple/core.cljs b/examples/simple/src/simple/core.cljs index cd656a5..e5c92af 100644 --- a/examples/simple/src/simple/core.cljs +++ b/examples/simple/src/simple/core.cljs @@ -1,6 +1,7 @@ (ns simple.core (:require [reagent.core :as reagent] - [re-frame.core :as rf])) + [re-frame.core :as rf] + [clojure.string :as str])) ;; A detailed walk-through of this source code is provied in the docs: ;; https://github.com/Day8/re-frame/blob/master/docs/CodeWalkthrough.md @@ -61,7 +62,7 @@ {:style {:color @(rf/subscribe [:time-color])}} (-> @(rf/subscribe [:time]) .toTimeString - (clojure.string/split " ") + (str/split " ") first)]) (defn color-input @@ -86,4 +87,3 @@ (rf/dispatch-sync [:initialize]) ;; puts a value into application state (reagent/render [ui] ;; mount the application's ui into '
' (js/document.getElementById "app"))) - diff --git a/examples/todomvc/src/todomvc/views.cljs b/examples/todomvc/src/todomvc/views.cljs index 5388041..7dad524 100644 --- a/examples/todomvc/src/todomvc/views.cljs +++ b/examples/todomvc/src/todomvc/views.cljs @@ -1,26 +1,27 @@ (ns todomvc.views (:require [reagent.core :as reagent] - [re-frame.core :refer [subscribe dispatch]])) + [re-frame.core :refer [subscribe dispatch]] + [clojure.string :as str])) (defn todo-input [{:keys [title on-save on-stop]}] - (let [val (reagent/atom title) + (let [val (reagent/atom title) stop #(do (reset! val "") (when on-stop (on-stop))) - save #(let [v (-> @val str clojure.string/trim)] - (when (seq v) (on-save v)) - (stop))] + save #(let [v (-> @val str str/trim)] + (when (seq v) (on-save v)) + (stop))] (fn [props] [:input (merge props - {:type "text" - :value @val - :auto-focus true - :on-blur save - :on-change #(reset! val (-> % .-target .-value)) + {:type "text" + :value @val + :auto-focus true + :on-blur save + :on-change #(reset! val (-> % .-target .-value)) :on-key-down #(case (.-which %) - 13 (save) - 27 (stop) - nil)})]))) + 13 (save) + 27 (stop) + nil)})]))) (defn todo-item diff --git a/src/re_frame/interceptor.cljc b/src/re_frame/interceptor.cljc index d22c7b1..fb99e0c 100644 --- a/src/re_frame/interceptor.cljc +++ b/src/re_frame/interceptor.cljc @@ -1,7 +1,8 @@ (ns re-frame.interceptor (:require - [re-frame.loggers :refer [console]] - [re-frame.interop :refer [ratom? empty-queue debug-enabled?]])) + [re-frame.loggers :refer [console]] + [re-frame.interop :refer [ratom? empty-queue debug-enabled?]] + [clojure.set :as set])) (def mandatory-interceptor-keys #{:id :after :before}) @@ -16,9 +17,9 @@ "Create an interceptor from named arguments" [& {:as m :keys [id before after]}] (when debug-enabled? - (if-let [unknown-keys (seq (clojure.set/difference - (-> m keys set) - mandatory-interceptor-keys))] + (if-let [unknown-keys (seq (set/difference + (-> m keys set) + mandatory-interceptor-keys))] (console :error "re-frame: ->interceptor " m " has unknown keys:" unknown-keys))) {:id (or id :unnamed) :before before @@ -195,4 +196,3 @@ (invoke-interceptors :before) change-direction (invoke-interceptors :after))) - From 2313c9d509a76d0da023bf0d297b7bdfe1da416e Mon Sep 17 00:00:00 2001 From: Prof Gra Date: Thu, 13 Jul 2017 15:37:27 +0200 Subject: [PATCH 2/4] Fix typo in comments of simple/core.cljs --- examples/simple/src/simple/core.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/simple/src/simple/core.cljs b/examples/simple/src/simple/core.cljs index cd656a5..ccc0ac2 100644 --- a/examples/simple/src/simple/core.cljs +++ b/examples/simple/src/simple/core.cljs @@ -13,7 +13,7 @@ (rf/dispatch [:timer now]))) ;; <-- dispatch used ;; Call the dispatching function every second. -;; `defonce` is like `def` but it ensures only instance is ever +;; `defonce` is like `def` but it ensures only instance one is ever ;; created in the face of figwheel hot-reloading of this file. (defonce do-timer (js/setInterval dispatch-timer-event 1000)) From 2ce934635c2f034bf12e0dcda9138d51944e0c02 Mon Sep 17 00:00:00 2001 From: Christophe Gragnic Date: Fri, 14 Jul 2017 07:14:55 +0200 Subject: [PATCH 3/4] Fix my fix 'only one instance' --- examples/simple/src/simple/core.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/simple/src/simple/core.cljs b/examples/simple/src/simple/core.cljs index ccc0ac2..4fc5882 100644 --- a/examples/simple/src/simple/core.cljs +++ b/examples/simple/src/simple/core.cljs @@ -13,7 +13,7 @@ (rf/dispatch [:timer now]))) ;; <-- dispatch used ;; Call the dispatching function every second. -;; `defonce` is like `def` but it ensures only instance one is ever +;; `defonce` is like `def` but it ensures only one instance is ever ;; created in the face of figwheel hot-reloading of this file. (defonce do-timer (js/setInterval dispatch-timer-event 1000)) From f7c368433808f86be28a61607ddc32de7264d7dc Mon Sep 17 00:00:00 2001 From: Christophe Gragnic Date: Fri, 14 Jul 2017 07:40:30 +0200 Subject: [PATCH 4/4] Simpler line in simple/core It also makes the code like in the walkthrough: --- examples/simple/src/simple/core.cljs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/simple/src/simple/core.cljs b/examples/simple/src/simple/core.cljs index cd656a5..4f77142 100644 --- a/examples/simple/src/simple/core.cljs +++ b/examples/simple/src/simple/core.cljs @@ -44,8 +44,7 @@ (rf/reg-sub :time (fn [db _] ;; db is current app state. 2nd unused param is query vector - (-> db - :time))) + (:time db))) ;; return a query computation over the application state (rf/reg-sub :time-color