Fork me on GitHub
#clojurescript
<
2020-03-04
>
lordie01:03:04

Hi, how do I deal with redefiniton of functions when using Form-2 reagent components? I don't want to loose the component state after changing the source code

lordie01:03:12

should I just use the global state?

☝️ 8
lordie01:03:52

form2 being this pattern

(defn counting-button [txt]
  (let [state (reagent/atom 0)] ;; state is accessible in the render function
    (fn [txt]
      [:button.green
        {:on-click #(swap! state inc)}
        (str txt " " @state)])))

Old account17:03:31

Hello! I have a error listener (set! (.-onerror js/window)(fn [message source lineno colno error]... like this on browser and it works well, but stacktrace and other fields are in JS. I would like it to be translated to ClojureScript. I have source map in the project. I guess that would help.

yenda18:03:35

I'm getting cljs.core/+, all arguments must be numbers, got [const number] instead when trying to sum an int with a constant declared like this (def ^const x) is there a way work around that and add and a constant with an int value?

delaguardo19:03:13

(def ^:const x) it should be a keyword instead of a symbol

delaguardo19:03:33

+ working just fine with constants )

yenda19:03:54

Thanks! I knew something was off 😄 I had one of these moments when you are so tired your brain is freezing

❄️ 4
thheller18:03:43

just don't use const? 😛

4
yenda19:03:05

what's wrong with const?

thheller19:03:27

doesn't give you anything?

yenda19:03:36

doesn't it eliminate the symbol by putting the value directly in the compiled code?

thheller19:03:39

yes, but the closure-compiler will do that for you as well (if you actually never change it)

thheller19:03:27

the "optimization" ^:const does for clojure is much less relevant for CLJS (IMHO) since there is no var root stuff

yenda19:03:54

ok thanks!

sheluchin20:03:21

How do I use Clojure libraries in a Clojurescript project? Is that a practical thing to do? I'm trying to use https://github.com/metabase/toucan in a Fulcro project. It gives me an error like this:

The required namespace "toucan.db" is not available, it was required by "sheluchin/client.cljs".
"toucan/db.clj" was found on the classpath. Should this be a .cljs file?

bfabry20:03:31

toucan depends on clojure.java.jdbc which depends on java

bfabry20:03:08

I think generally if a library is cross-compatible it will say so in the readme

sheluchin20:03:22

Ah, ok. Thanks.