Fork me on GitHub
#clojurescript
<
2018-08-13
>
Ferdi09:08:39

hello clojurescript community! When i define a defrecord i get for the type #object[function ]. in clojure i get java.lang.class. Is it possible to get a better tpename for defrecords in clojurescript?

thheller11:08:41

@ferdi.kuehne if you don't intend to the use classname for anything other than outputting it you can use (pr-str TheType)

pesterhazy12:08:59

Would it be possible to add a warning to the CLJS compiler when the filename doesn't correspond to the namespace? That's my no1 "hard to diagnose" problem

lepistane12:08:37

Are there any libs for cljs for using google maps that are up-to-date ?or any other map that has direction for that matter, yandex is ok too i found 2 updated 2013/2015 that seems outdated

pesterhazy12:08:58

@lepistane probably easiest to use a js/react based library, and use that directly with reagent/rum/whaterver wrapper you're using.

Karol Wójcik12:08:20

I am using the newest clojurescript and targeting Node.js. I am curious when was the change in compiler which auto direct all prints to the javascript console? I remember that in the past the (enable-console-print!) was a standard 😛 Now it's not needed as I can see. (which is great 😄 🎉 ) @mfikes

lepistane13:08:20

@pesterhazy even that recommendation lib would be great, i am not very experienced with this so linking how to.. would be nice too most useful thing i found was https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/google-maps and i will probably gonna use that but i was wondering if there are others that i can't find solo and community knows (i am talking about libs or blogs that teach u to use google/yandex map inside your project)

Karol Wójcik13:08:53

Great change ❤️ Thank you @mfikes

idiomancy15:08:32

anyone know how to select the :root element with garden? [::root] still compiles to root {} 😕

idiomancy15:08:14

oh, looks like ":root" works. that'll do 🙂

👍 4
JH17:08:08

Hey everyone, I was wondering if any of you would have a suggestion as to how to print the source for a function as a string (without using clojure.repl source / sourcefn )?

john18:08:09

The original lispy source? Or the compiled function?

JH18:08:50

@john lipsy source

richiardiandrea18:08:34

Hello folks! I have the following piece of code that is evaluated in a macro:

(cljs.test/async
 done
 (cljs.core.async/go
  (try
   (cljs.core.async/take!
    (go (is (nil? (<! (throwing-ch)))))
    (clojure.core/fn [val] (done)))
   (catch
    :default
    e
    (clojure.core/println "ERRORORORO")
    (cljs.test/do-report (shared.test.test/chan-error-map e)) 
    (done)))))

richiardiandrea18:08:40

the error never gets caught in the catch

richiardiandrea18:08:12

and I cannot understand why for life of me 😄

john18:08:28

@jacob.haag Outside of creating a custom macro defn that stores the source in the meta, I don't see any other way get at the source other than the route source takes

JH18:08:20

Okay, thanks John

hlolli18:08:36

@richiardiandrea you have 2 go's, I guess try/catch needs to be under 1 and the same go macro?

richiardiandrea18:08:08

I tried to add try/catch under the first one just now, no dice

richiardiandrea18:08:08

I tried to add try/catch under the first one just now, no dice

hlolli18:08:42

the catch should be js/Error not :default ?

john18:08:03

:default should catch all, I think

richiardiandrea18:08:18

yeah that is what I know as well

richiardiandrea18:08:28

this does not work as well:

(cljs.test/async
 done
 (try
  (cljs.core.async/go
   (try
    (cljs.core.async/take!
     (go (is (nil? (<! (throwing-ch)))))
     (clojure.core/fn [val] (done)))
    (catch
     :default
     e
     (clojure.core/println "ERRORORORO")
     (cljs.test/do-report (shared.test.test/chan-error-map e))
     (done))))
  (catch :default e (clojure.core/println "ERRORORORO2" e))))

john18:08:15

Is catch an implicit do block?

richiardiandrea18:08:02

yeah it is...it seems

thheller18:08:27

I'm assuming that (go (is (nil? (<! (throwing-ch)))) is the throwing part? the exception thrown there won't propagate to the outer go so the try/catch doesn't matter at all?

thheller18:08:55

and what is the point of that code in the first place?

richiardiandrea18:08:00

so this is part of a testing framework

richiardiandrea18:08:09

I am trying to catch as match as I can and report

richiardiandrea18:08:53

the thing is...I see the exception printed out in console

richiardiandrea18:08:17

so there must be a way to catch it somehow

richiardiandrea18:08:32

(hopefully not node hooks)

jmckitrick18:08:51

Is there an ‘official’ template for starting a figwheel project with all the latest stuff?

jmckitrick18:08:36

Cool, I’ll check it out. I know a lot has changed….

richiardiandrea18:08:31

oh wow, that's sad...

john18:08:05

Seems like you can't handle all possible downstream exceptions if they're fired async

richiardiandrea18:08:48

my throwing fn was:

(defn throwing-ch []
  (go
    (gobj/get (js* "undefined") :foo)))

richiardiandrea18:08:56

so I guess that's uncatchable

john18:08:58

maybe monkey patch js/throw 😆

justinlee18:08:59

you have have to catch exceptions generated on the producer side and then, if you want, stuff them in the channel. see dnolen’s <? operator

richiardiandrea18:08:12

yep I know that trick

richiardiandrea18:08:28

but this is a testing wrapper, so I do not have control over that

richiardiandrea18:08:49

you learn new things every day I guess 😄

justinlee18:08:50

your throwing-ch would have to wrap the call to gobj/get

richiardiandrea18:08:09

yep I understand that 😄

richiardiandrea18:08:24

but that is not under my lib control

justinlee18:08:31

oh okay. i just ran into this headlong a while ago and was very frustrated by the experience 🙂

richiardiandrea18:08:42

if a user does not do that, I thought I could still catch

richiardiandrea18:08:08

but thanks for chiming in folks, I genuinely did not know about -> https://bytearcher.com/articles/why-asynchronous-exceptions-are-uncatchable/

justinlee18:08:25

for example, cljs-http (which uses core.async) will throw an exception if the server returns bad json. but because it doesn’t catch it, it just dies. there’s no way to fix that from the consumer side.

👍 4
justinlee18:08:49

this is why i advocate for the use of promises over async blocks

richiardiandrea18:08:49

so there is almost no point in what I am doing with channels 😉

john18:08:57

If it's just for testing, monkey patching js/throw might be okay actually

richiardiandrea18:08:16

maybe yeah, you might be right

richiardiandrea18:08:14

my poor macro will have to die with the time I wasted writing it 😄

richiardiandrea19:08:12

I was afraid of that 😄

john19:08:33

Looks like node is:

process.on('uncaughtException', function(error) {
  // do something clever here
  alert(error); // do NOT do this for real!
});

john19:08:49

Yeah, I wouldn't do it in production 🙂

justinlee19:08:59

that’s going to be tricky in a testing framework, because you won’t know what test caused the error, and you won’t know how long to wait

richiardiandrea19:08:28

I guess for now I am going to postpone the whole idea...too much work for little gain

Wilson Velez21:08:07

Hi, can anyone help me? How print or format a value to show in an input field as currency or something like this (#,###.00)?

Wilson Velez21:08:03

what I have found is cl-format, or split the number in decimal part and integer part and format accordingly

Patrick Hildreth21:08:38

@wvelezva (.toLocaleString 550.753 js/undefined #js {:style "currency" :currency "USD"})

👍 4
aarkerio21:08:51

hi! does somebody know if I can split my code in namespaces in clojurescript?

dnolen21:08:40

do you mean splitting the final build into N pieces?

aarkerio21:08:51

no, I mean, calling "users/foo_function" from the core.cljs file doesn't work because all inside the "users" NS can't reach the DOM

aarkerio21:08:14

foo_function has: (gdom/getElement "icon-add") in it

aarkerio21:08:44

the function works fine if the function is in "core.cljs" file

aarkerio21:08:22

but when I move it to users and then (:require [zentaur.users :as users]

aarkerio21:08:37

the function is executed, but the DOM is never reached

dnolen21:08:40

hrm I don’t understand

dnolen21:08:58

it shouldn’t matter what namespace that function is defined as long as your requires are right

dnolen21:08:03

i.e. users requires goog.dom

lilactown21:08:55

@aarkerio you need to show more code. how are you requiring it? how were you executing the foo function when it worked?

lilactown22:08:25

I’m not able to tell if it can’t find the DOM node, or if something is up with the function you are passing in to events/listen

lilactown22:08:59

I would replace foo with (js/console.log (gdom/getElement "icon-add")) to see if it can find the dom node. if not, then I’m confused because that should 💯 work