This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-28
Channels
- # beginners (98)
- # cider (11)
- # clj-kondo (18)
- # cljsrn (4)
- # clojure (31)
- # clojure-uk (5)
- # clojuredesign-podcast (1)
- # clojurescript (18)
- # cursive (11)
- # dirac (5)
- # emacs (1)
- # figwheel-main (6)
- # fulcro (13)
- # off-topic (3)
- # pathom (3)
- # reagent (3)
- # rewrite-clj (1)
- # shadow-cljs (2)
- # tools-deps (19)
- # vim (2)
I'm trying a sample code in fulcro 3 development docs ...
(defonce app (app/fulcro-app))
(def example-person (atom {:person/name "Wilson" :person/age 46}))
(defsc Person [this {:person/keys [name age]}]
(dom/div
(dom/div
(dom/label "Name: " name))
(dom/div
(dom/label "Age: " age)))
)
(def ui-person (comp/factory Person))
(defsc Root [this props]
(dom/div
(ui-person @example-person)))
When i change example-person ..it's rendered immediately
However, if I change it to defonce
, changing example-person in REPL e.g (reset! example-person {:person/name "Abc" :person/age 25})
has no effect.
I have to do (app/mount! app Root "app")
to force a re-render
Can someone please explain why this is so ?
Could someone explain to me how to create macros in clojurescript. I've been trying to institute <? macro by hand but have gotten repeating errors. As far as I am aware, it is a compile vs runtime thing and requires that the macro must be defined at compile time and therefore must be in a seperated clj/cljc file? I have tried this but have not gotten much success
@sirromdev what have you tried? you basically just create a .clj
and a .cljs
file of the same name and then have the CLJS version (ns foo.bar (:require-macros [foo.bar]))
(ns eth.macros)
(defn throw-err [e]
(when (instance? #?(:clj Throwable :cljs js/Error) e) (throw e))
e)
(defmacro <?
[ch]
`(throw-err (cljs.core.async/<! ~ch)))
(ns eth.macros)