Fork me on GitHub
#clojurescript
<
2018-07-11
>
au-phiware00:07:34

hmmm... multiple class loaders... my project has a dockerfile that our CI uses for building which I wasn't using... next time I might try using it; it should be a cleaner environment...

mfikes00:07:12

Yeah, emit-constant dispatches on class in JVM ClojureScript, so you’d have to suspect multiple classloaders if there is somehow more than one JSValue class. https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/compiler.cljc#L231

👍 4
zakora07:07:57

I am looking for a way to use both Clojure and ClojureScript for a project. The goal is essentially to manipulate files at the OS level (using Clojure) and display the data in the browser (leveraging ClojureScript). Are there any frameworks/libraries/tools to run both Clojure and ClojureScript side-by-side? As far as I know, when using ClojureScript the result will only be JavaScript and not Clojure + JavaScript.

dominicm08:07:33

@zakora_clojurians sounds like you're trying to get the browser to communicate with a http server? So the obvious answer is that you write a http api in clojure, and call it from clojurescript. You can use cljc files to share logic in cljs & clj.

zakora08:07:13

@dominicm I'll have a look at cljc files, thanks!

zakora08:07:14

I was wondering if there were idiomatic ways to do this, but it might be a use case not very common.

dominicm08:07:09

I don't fully understand what you're asking. We use cljc a lot for some kinds of logic though. It's all dependent.

zakora08:07:33

@dominicm Yeah sorry, I see that my question is not clear. I guess I expected something like "This tool X provides an interface/protocol between Clojure and ClojureScript, so you can write code in Clojure to manage files, then use the X protocol to send data to ClojureScript, which in turns will use the X interface to parse the data; the X tool abstracts over WebSocket to do communication, it also provides a wrapper so you run a single command that will launch your Clojure app, your ClojureScript app and also setup the web server for them to communicate."

zakora08:07:17

Not sure if what I am asking is more clear now :face_with_rolling_eyes:

dominicm08:07:49

https://hoplon.io/ something like this might help with that.

zakora08:07:21

I will look into it, thanks!

au-phiware09:07:42

@zakora_clojurians, you can also write the server component in clojurescript and run it on node, consider https://macchiato-framework.github.io

zakora09:07:57

Looks interesting, thanks

idiomancy14:07:37

can anyone point me towards a primer on how to include static files for reagent/reframe projects? basically I have a [:img {:src <what goes here and where should I put the file>}] problem

samueldev14:07:05

@idiomancy if you're using a re-frame template project, there is a resources/public/... directory

samueldev14:07:29

that directory is considered the "web root". so a file @ resources/public/image.png would be referenced as :src "/image.png"

idiomancy14:07:47

okay, awesome, thanks. That's exactly what I needed 🙂

mfikes14:07:34

@au-phiware A patch now exists in https://dev.clojure.org/jira/browse/CLJS-2813, which may help in sorting out which bit of code of yours is throwing under boot. Instructions on how to apply a patch like this are in http://blog.fikesfarm.com/posts/2016-02-22-trying-clojurescript-paches.html

john15:07:18

@zakora_clojurians If you look at some lower-level, older schemes for getting up-and-running with you CLJS, you'll see that all the CLJS build stuff sits on top of a clojure API. Check out the .clj files here, for instance: https://github.com/swannodette/mies/tree/master/src/leiningen/new/mies

🙂 4
john15:07:34

So, technically speaking, the backend of any CLJS repl is actually running in Clojure already. You just want that brepl process to be running in the process of the Clojure server. So you could follow the mies template structure to get your self going down that road. There's probably already ring handler that does all that though.

john15:07:10

... if I understand your question correctly

zclj18:07:06

I have a clj server with a cljs client where I share some specs. Some of the specs include uuid?. Client/Server speak transit. I was surprised when a spec validation failed on the client for data that I would expect to be valid. It also validated on the server without problem. Looking a bit deeper I found that the cljs transit reader return a transit/UUID (as documented) not a cljs.core/UUID. The transit/UUID do not validate with uuid?, therefor my validation fails. On the server side the clj reader return a java.util.UUID which passes the uuid? test. Can anyone give any hints on: 1. What is the rational for cljs transit to not return a cljs.core/UUID? 2. Is there any reasonable workaround? Maybe make my own validation spec instead of uuid??

oscar18:07:05

I ran into this, too. If I remember correctly, it's because transit-cljs was released before uuid was a native cljs type. To fix, just include the line

(extend-type com.cognitect.transit.types/UUID
  IUUID)

zclj19:07:34

Will try, thx!

zclj19:07:03

Thanks for the info! The extend-type workaround solved my problem. +1 for adding it to transit since it is quite a surprise that it do not work out of the box

mikerod21:07:01

The user ns shouldn’t be relevant given the profiles active. I’m not sure why it tries to find it. It also still is a successful build

john21:07:19

do you have a user file? in /dev?

Marcin21:07:01

To anyone interested in Firebase, I’ve created a small template for Reagent / Re-frame / Firebase / Material UI https://github.com/suseek/reframe-reagent-firebase-materialui-template

john21:07:45

@UA7P1BSJJ What's your opinion on firestore?

john21:07:09

wrt integrating with CLJS? Have you worked with it?

Marcin06:07:06

I would love to work with it, but as I find a few issues within’ beta state of firebase functions (like you cannot change the region just yet), I don’t want to dive into another beta programme

Marcin06:07:06

But if your app is not going into production, then I would say sure, go for it — that’s the future of Firebase.

👍 4
john21:07:03

@mikerod and are you using a more recent version of CLJS? The only thing I recall changing WTR user is this: https://dev.clojure.org/jira/browse/CLJS-2298

mikerod21:07:17

@john I do have a dev/user.clj, but it isn’t in the :source-paths or :resource-paths when running this (intentionally)

dnolen21:07:29

also only applies to REPLs

dnolen21:07:39

I don’t see how that change would impact builds

mikerod21:07:46

I’m not sure why lein-cljsbuild would be looking for it. I don’t have a minimum repro or anything though, so just seeing if anyone recognizes the error enough for any pointers

mikerod21:07:03

using [org.clojure/clojurescript "1.10.312"]

mikerod22:07:38

Ok, unrelated question: Google closure externs - I find it hard to find much documentation about the rules to how to write/read them. The example https://developers.google.com/closure/compiler/docs/api-tutorial3#externs is really basic and doesn’t show more cases. I look at examples that are more intricate like, as an example https://github.com/google/closure-compiler/blob/811dd9c4f6ba67d74578c817de7f7a234af511a9/externs/browser/w3c_dom1.js#L165 Which is Node.prototype.nodeName; - Does it the actual need the class name given, Node, or could it just be Object.prototype.nodeName;? Would doing something like Object.prototype.nodeName cover anything referred to as nodeName or is there some sort of type inference in play that makes Node more restricted to only apply to things found to be a Node? In general, it’d be nice to gather some more understanding of how these externs are interpreted.

mikerod22:07:13

As of now, the only method I know is to go read some of the closure code to find out (which may be on the agenda).

dnolen22:07:00

that’s right

dnolen22:07:06

Object is less specific than Node

dnolen22:07:16

there’s really not much else to it

dnolen22:07:28

you can put as little information as you like in an externs file

dnolen22:07:52

the more stuff you put like @constructor, @param, @returns etc. mean Closure will do more checking

dnolen22:07:57

foo.bar; is fine

dnolen22:07:08

foo.bar = function() {} is more informative etc.

mikerod22:07:16

Yeah, I knew that closure had more it can do with the annotations and such. Just never knew what parts were “necessary” to avoid the name munging vs other things.