Fork me on GitHub
#beginners
<
2018-08-08
>
seancorfield00:08:06

@takamura.developer I think it's fair to say that Om.Next is very opinionated compared to Reagent. Some people like an opinionated framework, some don't.

takamura.developer00:08:46

Cool! I will try more reagent tutorials then, thanks!

donaldball00:08:55

I did a project in om.next and I confess it never gelled for me. I repeatedly had the experience of reading the documentation, having a false moment of realization, then sitting down to code and realizing I had no idea how to go about what I wanted to do.

takamura.developer00:08:45

What about tools? the usual tools for cljs development are: lein ou boots? figwheel or cljs-shadow?

seancorfield01:08:07

@takamura.developer I can't give you much guidance on cljs tooling -- it's evolved a lot since I last tried to use it all (it was pretty bad three years ago! πŸ™‚ ).

jaihindh.reddy06:08:11

@takamura.developer You may wanna check out qlkit. It is a much simpler implementation of the concepts behind Om Next. About 300 lines of code. You can read the source to understand the concepts and then go about using Om Next. https://medium.com/@conrad_9565/lets-build-a-ui-with-qlkit-and-graph-queries-79b7b118ddac https://github.com/forward-blockchain/qlkit

danieleneal08:08:34

ooh I'd not heard about qlkit

cristibalan12:08:03

Where can I clear some caches if I keep getting an obviously wrong "Too many arguments to if" compile error? It only happens in one place under a cond->. It compiles if I remove the if, if I move the if out of the cond->, or in another function, or if I remove the cond->. CI seems to have passed on this code as well so it looks like a local issue.

dpsutton12:08:49

are you sure your if is playing correctly with the threading of the cond->?

cristibalan12:08:20

Oh, you mean the first arg will be threaded into the condition part of the if!

cristibalan12:08:20

@dpsutton Thanks for the hint. I was so convinced it was a local issue because CI seemed to have passed. I just noticed I pushed to the wrong branch tho πŸ™„

cristibalan12:08:52

I guess putting ifs into a cond-> is not such a good idea then.

dpsutton12:08:52

well the cond-> should have the test above the threading part

cristibalan12:08:28

I was trying to avoid having thing (fn) (not thing) (other-fn).

dpsutton12:08:59

you could put the if statement at the top around the value you are threading

dpsutton12:08:17

(cond-> (if condition? map1 map2) ...)

cristibalan12:08:26

Not really. The threading that goes on before is actually relevant.

cristibalan12:08:36

Sorry for being brusque above. I'm enqueueing some pedestal interceptors so I can't move the if before.

dpsutton12:08:54

(cond-> v condition (assoc ...) (not condition) (assoc ...)) is pretty standard

dpsutton12:08:32

I didn't follow your (fn) (not thing) (other-fn)) stuff above.

cristibalan12:08:19

I meant I was trying to avoid exactly your cond-> example with the thing and (not thing) predicates as I felt it looks like "bad usage for cond->".

cristibalan12:08:36

So I tried to be smart and use an if instead πŸ™‚

dpsutton12:08:41

feels normal to me Β―\(ツ)/Β―

cristibalan12:08:58

Well, sometimes I am using cond-> with just one predicate to avoid repeating things so, maybe my radar is a bit off πŸ™‚ [edited for clarity]

loganpowell13:08:41

I believe I'm running into issues trying to use ClojureScript code as a callback within a JavaScript Library function. Is this a typical interop issue?

loganpowell14:08:11

perhaps I should ping the #clojurescript channel on this one?

carr0t14:08:35

Hmm. I've not done enough ClojureScript to be sure. I know it's not an issue with Clojure/Java, because we're doing it, but we did have to reify the thing we wanted to do so that Java saw it as a Java class with a method:

(reify Callback
    (onCompletion [_ metadata exception]
      (if exception
        (log-message :error (produce-exception-log exception))
        (log-message :debug (wrote-message-log metadata)))))
Is there something akin to reify for ClojureScript/JavaScript?

loganpowell14:08:23

yes, there's a reify macro in cljs

loganpowell14:08:30

I've never used it though πŸ˜„

loganpowell14:08:37

I'll give that a go

carr0t14:08:53

So that was where the Java lib was expecting a callback that implemented the interface Callback (with some org.blah stuff before, but we'd imported that), which required it to provide an onCompletion function

loganpowell14:08:39

thank you for the pointer, let me google around

mario.cordova.86215:08:24

Question: I was reading a StackOverflow question. https://stackoverflow.com/questions/25439971/library-functions-vs-java-methods-in-clojure And in the accepted answer the responder said >Normally, I prefer to use wrapped Clojure functions, unless I have benchmarked and identified a performance problem, at which point I might drop down to direct Java interop. I always thought that Clojure code becomes Bytecode and Java code also becomes Bytecode that the JVM then runs. If so then why would someone need to drop down to direct Java interop if the both languages end up in essence as Bytecode?

lilactown15:08:34

Clojure is: 1. very dynamic 2. uses immutable data structures #1 means that sometimes the JVM is not able to optimize execution of the bytecode that Clojure is turned into because it can’t guess as easily what it’s trying to do. #2 means that, for certain operations, using a Clojure data structure will be much slower than using a raw typed Java HashMap or Array that you mutate

jgh15:08:46

seems like they're referring to reflection, which i guess is easier to avoid with statically-typed syntax

mario.cordova.86215:08:19

I see what you are saying! @lilactown

mario.cordova.86215:08:41

@jgh Ive never heard of reflection. Going to google that lol

chris.schreiner16:08:56

Any specific reason why this fails with a `Class cast exception, trace missing: (map int (split (name :1-2) β€œ-”))

chris.schreiner16:08:10

split is from clojure.string

dpsutton16:08:40

(int "2")
ClassCastException java.lang.String cannot be cast to java.lang.Character  clojure.lang.RT.intCast (RT.java:1213)

dpsutton16:08:10

(map #(Integer/parseInt %) ["1" "2"])

dpsutton16:08:35

do you have two accounts?

dpsutton16:08:42

are you chris and Chrisp?

dpsutton16:08:01

haha i was confused by the really appreciative lurker lol

chris.schreiner16:08:45

the #error{:cause nil, :via [{:type java.lang.ClassCastException, :message nil}], :trace []} is not very … informative?

chris.schreiner16:08:01

but, hey, thanks

chris.schreiner16:08:58

so, this Integer/parseInt does not exist in cljs

chris.schreiner16:08:19

but I guess it is the int that balks

dpsutton16:08:03

js/parseInt in javascript. Integer/parseInt is a static method in the Integer class definitely jvm specific

dpsutton16:08:42

probably want the radix in it as well. Its easy to end up with a different base depending on input

chris.schreiner16:08:47

I don’t know what I`m doing wrong, since the repl balks at js/parseInt

chris.schreiner16:08:02

CompilerException java.lang.RuntimeException: No such namespace: js, compiling:(null:0:0)

dpsutton16:08:52

you said this was a cljs file right?

dpsutton16:08:01

i don't know how cursive works then. did you try the Integer/parseInt? is it possible cursive thinks this is a clojure file not clojurescript?

chris.schreiner16:08:18

I dunno, always have problems with the js namespace in cursive

chris.schreiner16:08:56

So I guess it is something wrong I’m doing related to the setup

dpsutton16:08:43

there's a #cursive channel to help you go through it

chris.schreiner16:08:13

yes, I think thats the proper way

chris.schreiner16:08:47

thanks for the input though

cureadvocate17:08:04

What is the best/recommended way to start a new ClojureScript project? I saw the devcards template, but idk if there's a more common option.

cureadvocate18:08:54

Reading prior comments, reagent does look pretty nice.

pez18:08:59

Reagent is nice. So is Rum. In the project I am involved in we switched from Reagent to Rum because it was trickier to do server rendering of the views in the former. I think that might have changed.

pez18:08:44

Earlier today, some messages up in this channel I heard of Qlkit, which looks really interesting. I think I will try to follow that tutorial and see what I think after that: https://medium.com/@conrad_9565/lets-build-a-ui-with-qlkit-and-graph-queries-79b7b118ddac

sundarj22:08:53

i recommend giving #fulcro a try as well. it's a batteries-included, easier to get started with, better documented fork of Om Next. the author is active in Slack if you should need to ask any questions, and has created a detailed book, as well as a series of videos to help people learn it. http://fulcro.fulcrologic.com cc @

cureadvocate18:08:45

Thanks for the heads up, pez.

bill.kempf19:08:16

I'm looking for advice on naming conventions for tests in clojure, especially for generative tests using test.check.

jarvinenemil23:08:18

Anyone with experience using https://github.com/ptaoussanis/sente? Need to do some real time updating stuff.

seancorfield23:08:14

@jarvinenemil We built some real time p.o.c. dashboard stuff at work using it -- but that was several years ago.