Fork me on GitHub
#clojurescript
<
2018-09-25
>
idiomancy01:09:17

does ^:dynamic do anything at all in clojurescript?

idiomancy01:09:34

I mean I'm thinking not, right?

justinlee01:09:26

doesn’t appear to from the repl, but I’ve never really understood this aspect of cljs

rsslldnphy06:09:38

any vim and node repl users run into a problem with println / .log console output not displaying when running code via piggieback?

rsslldnphy06:09:19

(i have called (nodejs/enable-util-print!))

chrisps07:09:45

how can I dispatch on (type) in clojurescript using multimethods? Intuitively I was thinking about (defmulti foo (fn [t] (type t)) (defmethod foo bar/baz-record-type [t] :whatever) but I cannot get this to dispatch on other than the default.

chrisps07:09:00

The response I get is a #object[TypeError TypeError: e.call is not a function]

chrisps07:09:45

So, what is this e, and where can I find it?

chrisps07:09:32

I should mention I evaluate all of this in the repl, that could be an issue

orestis07:09:44

What is t in this context? And should (type t) return :whatever ?

chrisps07:09:08

t is a record

chrisps07:09:49

I want to dispatch on instances of defrecord

chrisps07:09:49

suddenly it works, perhaps the repl was polluted

orestis07:09:30

I believe (I’m not 100% sure on this) that multimethods that dispatch on type only can be replaced with protocols?

chrisps07:09:57

I remember something similar

benzap07:09:39

Yeah, you might have an easier time with a protocol

chrisps07:09:59

I cannot eval defmulti’s in the repl

chrisps07:09:19

So they have to be compiled

benzap07:09:25

so (defprotocol Foo (foo [this])), then in the record (defrecord Bar [x y z] Foo (foo [this] (println "I am Bar!" x y z))) (foo (->Bar 1 2 3))

benzap07:09:35

you can also extend protocols using extend-protocol

benzap07:09:34

note that you can also extend the clojure(script) basetypes as well, so you could extend js/String, js/Number, as a default, js/Object

orestis07:09:55

Note that multimethods, once defined (the defmulti, not the defmethod) can’t be overwritten. You have to do some special invocation to undefine it first. Perhaps this is what you are experiencing?

chrisps08:09:17

@orestis Yes, this is it

orestis08:09:51

It’s so annoying. I can’t remember the syntax on how to undefine them, but it’s possible.

jmckitrick14:09:28

I’m watching ‘David Nolen: Embracing Simpler Tools’ right now. Are slides available for this talk?

mfikes14:09:50

Why do you need slides when you can just look at David? 🙂

yenda15:09:42

Is there a way in clojurescript to compile conditionally depending on target platform ? Something like reader conditionals but for ios and android for instance.

jmckitrick16:09:53

@mfikes lol, true, but I’d love to try some of the things he demoed.

mfikes16:09:48

I agree. Joking aside, I watched his talk as well, and had to imagine things. I'm not aware of any slides. (Actually, it looked like a lot of what David did was wing things at the terminal.)

jmckitrick16:09:54

Part of the reason why I’m asking is I’m putting together a presentation for a Clojure meetup, and I’m trying to decide how many new concepts I want to use. The demo is mostly figwheel-main, but I’m deciding between lein and CLI deps.

dnolen16:09:29

CLI deps has way fewer concepts, I don’t think thats a controversial statement

dnolen16:09:43

as it just does way less

idiomancy18:09:41

Any popular solutions out there for logging/log aggregation on a client only cljs web app?

dnolen18:09:22

Google Closure Library has a decent logging thing

idiomancy18:09:00

Where does it send them?

idiomancy18:09:24

Looks like loggly has an endpoint for browsers too. I have mixed experiences with loggly though...

dnolen18:09:27

oh sorry I missed the aggregation bit

idiomancy18:09:47

Yeah, im considering sending everything to s3 and then using spectrum or whatever to query it later, but that gets me pretty deep into AWS stack...

dnolen18:09:51

depending on your other choices you could also just use the AWS SDK from the browser to log via CloudWatch

jaawerth19:09:32

@idiomancy I haven't used it with cljs, but one lib I've been tinkering with using both in frontend and (node) backend is pino, which is an extensible lightweight logging lib that logs in ndjson format, which is very nice for sending over the wire. So you could set it up to log things back to a server that then aggregates or converts and then aggregates as needed. It also supports loglevels https://github.com/pinojs/pino It should be pretty easy to wrap from cljs

jaawerth19:09:00

that's totally separate from the transport though - it's BYOTransport 😉

jaawerth19:09:33

which tbh is my preference anyway. there are some pre-existing ones for pino though https://github.com/pinojs/pino/blob/master/docs/transports.md#known-transports

aarkerio19:09:45

hi! quick newbie question: in "(let [news-list @(subscribe [:news])]" what "@" is for?

aarkerio19:09:19

an atom reference?

jaawerth19:09:23

dereferencing a.. thing. probably an atom (or a ratom if you're in the context of reagent)

aarkerio19:09:50

yeah, is a reagent/re-frame tutorial, thanks!

idiomancy19:09:52

Im actually thinking I might just make a simple lambda function to push logs onto s3

idiomancy19:09:11

Then I can use whatever logging lib makes sense

jaawerth19:09:30

yeah, I'd definitely set up the transport as a separate pluggable thing from your logging lib either way

currentoor20:09:23

i heard it’s easy to have memory leaks when using cljs and core.async is there a post, or docs, on how to avoid that? if a channel is no longer referenced will it get cleaned up? or do i need to explicitly close all channels i open?

dnolen20:09:59

hrm, it’s really not that easy

currentoor20:09:21

that’s good to hear simple_smile

currentoor20:09:17

i’m building a cljs that will run longer than a typical web app i’m used to building

dnolen20:09:18

as long you’re tasteful and moderate with your core.async usage I don’t think this will be a problem

dnolen20:09:40

if you do find it to be a problem - Chrome Heap Snapshot can usually spot these problems

dnolen20:09:47

the only time I debugged core.async memory issues was when I worked on core.async itself