Fork me on GitHub
#shadow-cljs
<
2020-06-30
>
frankitox01:06:20

Hi! I'm using shadow-cljs hooks (`:flush`) to trigger a little Linux command to show a notification in case a warning happens. I'd like to do the same thing each time an error appears, but none of the hooks seem to help

magra08:06:30

at thheller: I just startet using tap on the ring-request. Thank you!!!!! Very nice!!

👍 3
pmooser10:06:14

Does anyone know what the right way to require something like CodeMirror is? When I'm using random JS packages, I'm often a bit confused by the require/import statement.

thheller10:06:22

(:require ["codemirror" :as cm])

pmooser10:06:40

If I do something like (:require ["CodeMirror" :as cm]) then cm itself seems to be a function?

thheller10:06:46

yep, the constructor to be precise. so you (cm. #js {:opts ...})

pmooser10:06:28

So when I see an example like, CodeMirror.fromTextArea() ... how do I reach that?

thheller10:06:37

cm/fromTextArea

pmooser10:06:46

Huh, wow, really? I'm so confused!

thheller10:06:14

well (.fromTextArea cm ...) is also ok

thheller10:06:50

usually :as just sets up an alias but in case of JS requires it may also be used as an object

pmooser10:06:52

Ok, thank you ! Not being much of a JS guy, I've never quite understood exactly how those JS namespaces/etc get mapped into cljs.

thheller10:06:56

exactly as in CLJ basically the only difference is that CLJ doesn't allow :as foo using foo directly where each def would be a property of that foo

thheller10:06:13

since JS doesn't have real namespaces we can cheat ... 😛 and JS frequently does

pmooser10:06:38

But like periodically I see things that don't exist in CLJ, like :default (I think?) ...

pmooser10:06:16

Thank you ...

thheller10:06:36

because CLJ or Java have no such concept. thats strictly about being able to use JS features as intended

pmooser10:06:55

Ok, that table is extremely useful.

pmooser10:06:00

(as a translation guide)

pmooser10:06:37

I see an example where someone is using cljsjs, and they require the clojure mode for CodeMirror like:

cljsjs.codemirror.mode.clojure

pmooser10:06:27

I don't quite understand how to do that, or translate it, to shadow-cljs using the npm directly.

pmooser10:06:43

Maybe if I understood a little more about the layout of an npm compared to the github repo for CodeMirror.

pmooser10:06:15

Maybe something like this: ["CodeMirror/mode/clojure/clojure.js"]

pmooser10:06:41

Yeah, I think that did it allright.

gmercer10:06:24

Hi, I was trying to println debug my routes and the output seems to be swallowed by shadow - is there a way around this ?

gmercer10:06:28

(def dev-handler (-> #'routes wrap-reload push-state/handle)) - this is the dev-handler generated from the re-frame template - I got a prn to work upon the load of the handler namespace

thheller10:06:58

I recommend running any kind of server-related code separately. leave shadow-cljs out of it. you won't have shadow-cljs in production either so don't tie it to your development server either.

gmercer10:06:47

Cool - I was wondering if there was a logger type interface to spit out something in the short term ?

gmercer10:06:50

otherwise I should just include a logger (timbre etc.) to get it to land in a file

thheller11:06:53

as I said .. keep it separate then you can do whatever you want

thheller11:06:49

everything else you are on your own

gmercer11:06:09

No worries - thanks