From 39ffad78998f78eea946df87cc5bc49ec5493983 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Wed, 23 Nov 2022 13:23:35 +0100 Subject: [PATCH] re-frame tweaks --- CHANGELOG.md | 1 - resources/public/index.html | 22 +++++++++++++++++++++- shadow-cljs.edn | 5 +++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04487bb..c23c5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,6 @@ - Add `scittle.re-frame` plugin. This gives access to the [re-frame](https://github.com/day8/re-frame) library. - - Fix for [44](https://github.com/babashka/scittle/issues/44): Honoring `SCITTLE_NREPL_WEBSOCKET_PORT` in `scittle.nrepl` - Add all public vars of `cljs-ajax` `ajax.core` - Upgrade several built-in libraries diff --git a/resources/public/index.html b/resources/public/index.html index 0933342..e3f4950 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -6,6 +6,7 @@ + @@ -20,14 +21,26 @@ (def state (r/atom {:clicks 0})) + #_(require '[re-frame.core :as rf] + '[reagent.dom :as rdom]) + #_(rf/reg-event-fx ::click (fn [{:keys [db]} [_]] {:db (update db :clicks (fnil inc 0))})) + #_(rf/reg-sub ::clicks (fn [db _] (:clicks db))) + (defn my-component [] [:div [:p "Clicks: " (:clicks @state)] - [:p [:button {:on-click #(swap! state update :clicks inc)} + [:p [:button {:on-click #(do (swap! state update :clicks inc) + #_(rf/dispatch [::click]))} "Click me!"]]]) + #_(defn re-frame-component [] + (let [clicks (rf/subscribe [::clicks])] + [:div "Clicks:" @clicks])) + (rdom/render [my-component] (.getElementById js/document "app")) + #_(rdom/render [re-frame-component] (.getElementById js/document "re-frame")) + (require '[ajax.core :refer [GET]]) (defn handler [response] @@ -108,6 +121,13 @@
+ + +

Re-frame plugin

+ + To enable reagent, + in addition to the files needed for reagent, you need to include scittle.re-frame.js. +

Cljs-ajax plugin

diff --git a/shadow-cljs.edn b/shadow-cljs.edn index 29bd674..47e5deb 100644 --- a/shadow-cljs.edn +++ b/shadow-cljs.edn @@ -18,12 +18,13 @@ :depends-on #{:scittle}} :scittle.promesa {:entries [scittle.promesa] :depends-on #{:scittle}} - :scittle.re-frame {:entries [scittle.re-frame] - :depends-on #{:scittle}} :scittle.pprint {:entries [scittle.pprint] :depends-on #{:scittle}} :scittle.reagent {:entries [scittle.reagent] :depends-on #{:scittle}} + :scittle.re-frame {:entries [scittle.re-frame] + :depends-on #{:scittle.reagent + :scittle}} :scittle.cljs-ajax {:entries [scittle.cljs-ajax] :depends-on #{:scittle}}} :build-hooks [(shadow.cljs.build-report/hook)]