This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-02
Channels
- # admin-announcements (3)
- # architecture (5)
- # beginners (10)
- # boot (223)
- # cider (13)
- # cljsjs (2)
- # cljsrn (50)
- # clojure (208)
- # clojure-austin (16)
- # clojure-belgium (1)
- # clojure-india (1)
- # clojure-poland (13)
- # clojure-russia (130)
- # clojure-spec (27)
- # clojure-uk (144)
- # clojurescript (135)
- # css (2)
- # cursive (10)
- # datavis (1)
- # datomic (29)
- # dirac (9)
- # funcool (2)
- # hoplon (41)
- # jobs (3)
- # leiningen (6)
- # om (37)
- # onyx (20)
- # pedestal (1)
- # planck (1)
- # proton (4)
- # re-frame (45)
- # reagent (17)
- # rethinkdb (16)
- # ring-swagger (19)
- # schema (5)
- # specter (93)
- # sql (16)
- # test-check (33)
- # untangled (7)
I’m newly a JS dev, and I would like to write scripts (planck), UI (rum/figwheel), and node (figwheel?). But I when I was tinkering a couple years ago I was pretty JVM focused.
Thanks, @anmonteiro, I didn’t realize cljs.spec was a thing
anybody here using a CSS preprocessor with lein / figwheel ? (I am leaning towards stylus but SASS is second pick).
I'm using SASS
you can check out this guide: https://github.com/bhauman/lein-figwheel/wiki/SASS-watcher
I didn't follow it because I thought it was a bit messy, instead I did :figwheel {:css-dirs "resources/public/css"}
to watch CSS files in that directory then ran a seperate instance of sass --watch ...
hello guys, is there a public registry for clojurescript libraries similar to http://npmjs.com?
doesnt appear on top when you google for “clojurescript libraries” 😕
but yes, thanks, was looking for that
well, the distinction isn't made that clear between clj and cljs libs because both are packaged in JARs and some libs work in both clj and cljs.
What's the proper way to use core.async from clojurescript when using leiningen? i.e. Which package to depend on? And do I need to do anything different from what I'd do when using clojure to require
it?
It's the same core.async
package, you require cljs.core.async
but keep in mind that macros in CLJS needs to be explicitly imported.
@si14: any idea? Got a warning that I'm totally fine with, and very eager to kill it 🙂
i’m not sure if the community at large could use this, but i have a lot of code samples where i’ve basically translated js stuff into cljs versions that could be good examples; it was a lot of pain for me to learn like this and i - think - it might be helpful for others?
it’s definitely not idiomatic code, but it is the same output for both js and cljs versions
examples : https://github.com/xtrntr/cljs-d3/tree/master/src/cljs/cljs_d3 https://github.com/xtrntr/cljs-2048
@urbanslug: I think you need figwheel / boot-cljs-repl in your project.
folks; if I use boot as my build framework with (cljs-repl), it tells me sth like:
nREPL server started on port 62683 on host 127.0.0.1 -
Adding :require adzerk.boot-cljs-repl to index.html.cljs.edn...
However if I connect to that REPL using intelllij cursive, and try to load a CLJS file it tells me it can't load ClojureScript files into a Clojure repl. Is that a cursive issue or am I doing something wrong?@adamw you need to call (start-repl)
to get into a cljs repl
@urbanslug: figwheel then
@martinklepsch: ok, thanks. so I ran that and I got
<< started Weasel server on ws://127.0.0.1:62807 >>
<< waiting for client to connect ... Connection is
Writing boot_cljs_repl.cljs...
but cursive still refuses to recognise it as a cljs repl; and I can't connect to 62807. Guess I need to use a browser/weasel setup not intellijOh, you do have a cljs repl to connect to then. Not sure about it if it's an emacs problem.
@dominicm: So I should run a repl from the terminal and have emacs connect to that?
@urbanslug: I don't use emacs/cider, so I really don't know.
@adamw the websocket port is not meant to be connected to. You could try doing the same from a terminal REPL session to diagnose if the issue is w/ cursive or with your overall setup
I've used transit's read
but I don't know what's the proper way to traverse the returned value.
@skeuomorf: google closure library has tools for working with JSON, that would be first thing I would use, if only JSON parsing is needed: https://github.com/google/closure-library/blob/master/closure/goog/json/json.js
the return value is normal js object, so you can use JS interop to work with it, or you can convert it to cljs with js->clj
function (but that is not always the right choice depending on your needs)
namely js->clj can have poor perfomance for huge data, and can choke on some “weird” javascript objects, e.g. circular references
btw. many cljs.core functions recognise javascript arrays and can use them as sequences interchangeably, e.g. (map f js-array) will work, f will be called for each element of the array. This way I believe you can write some traversing code with cljs.core functions and resort to JS interop only in leaves.
and one last note: if you end up with cljs data structure (e.g. via transit’s read
or by calling js->clj
), you can use clojure.walk
for traversing the structure, or even clojure.zip
All these methods though will have me traverse the whole response and doing idx+1 to get the value that I want, right? i.e. I can't get a JS object literal -> Map with keywordized strings
Anyone have experience setting up figwheel to be accessible to other machines on the local network? I've tried all the figwheel client-side settings: using the client's connected host :websocket-host :js-client-host
, explicitly defining the host-name :websocket-host "myhostsname"
, overriding the websocket-url :websocket-url "
. All of these things correctly modify the websocket-url in figwheel/connect.cljs
file where the client websocket is started, but my clients always seem to ignore this and try to connect to '
. Am I missing something?
@spinningtopsofdoom: thanks again for the heads-up for the Slack.
Glad I could help you out 🙂
@jaemk: You could set up a socket repl with figwheel then connect to it with tubular (https://github.com/mfikes/tubular)
@spinningtopsofdoom: Thanks for the suggestion. My issue is the browser isn't connecting to figwheel's 'reload socket'. I can see in the compiled js that the websocket url is correct (pointing to the correct host), but the browser always tries to connect to localhost instead.
Ah I just read the first line, ooops. The modifications to the host show up in figwheel/connect.cljs
and the complied JavaScript, correct?
Yes, but the browser still tries connecting to
instead of the url that's in figwheel/connect.cljs
I think I found it look at https://github.com/bhauman/lein-figwheel/blob/bb32c895040413159ea7d00556b3ec2cf4a0aed9/support/src/figwheel/client.cljs#L293. It uses the location.host of the browser to connect if localhost isn't specified. So you'll have to have the url have http://myhostsname/
Shouldn't that be overridden by the options I'm providing though? https://github.com/bhauman/lein-figwheel/blob/bb32c895040413159ea7d00556b3ec2cf4a0aed9/support/src/figwheel/client.cljs#L365 . The complied figwheel.client.connect.js has the following figwheel.client.start.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"build-id","build-id",1642831089),"app",new cljs.core.Keyword(null,"websocket-url","websocket-url",-490444938),"
Yep I see you're correct, hmmmm. Do you know where in the compiled JavaScript ws//localhost....
is located?
Hi! For some reason I'm having trouble with this: In a macro I want to generate a list expression for ClojureScript and in there is a function call that I want to be evaluated in ClojureScript. So something like ({:foo (my.cljs/fun 1 2)} {:bar :baz})
. So as far as ClojureScript is concerned, the outer (...)
should remain a list (and not be treated like a function call) and the inner function call should be called and replaced with its result. Any ideas how I do that?
@darwin: Of course, that works. 🙂 I had list
there before but something else wasn't happy about it. Probably my tests being too strict about the generated syntax.
Hi, is there any way how to use and
dynamically with apply
?
@honzabrecka: and
is a macro so you’ll need to write a macro that does that. something like:
(defmacro apply-and [& body]
`(and ~@body))
untested@anmonteiro: that's essentially the same thing as and
🙂
wow that is indeed
@anmonteiro: Thanks! Without & before body argument it works exactly as I wanted.
@honzabrecka: exactly
that would be the fix
@honzabrecka: (every? identity coll)
does what you want if you only care about truthyness
@darwin: I don’t think that’s the case for and
@darwin: +
, -
, … macro and fn at the same time, and
, or
macro only
@darwin: What if I need to generate ({:foo (my.cljs/fun 1 2)} {:bar :baz})
exactly like that, without the list
?
Is there some way to generate (...)
without ClojureScript thinking it's a function call?
The code that generates this is pretty complex. What I want to generate is an Om Next query expression, so something like [({:user (om/get-query User)} {:id ?user-id})]
. Sadly, Om Next expects parameterized queries to be (<query> <param map>)
not (list <query> <param map>)
.
so it means, that the code you are normally writing by hand gets quoted by some other macro, I would suppose
so your own “inner” macro can simply generate (…)
because it gets quoted by other macro expansion
Doesn't that pass (<query> <param map>)
up to ClojureScript, which will then think (...)
is a function call instead of a list?
consider (outer-macro (my-macro (…)))
, my-macro can produce unquoted code, if outer-macro takes it and quotes it, cljs will evaluate the result after all macros were expanded
This is what I'm generating for ClojureScript at the moment: https://gist.github.com/Jannis/9c0e8efc9c6fc71547f0cc26ec3b06ce
The problem is: ClojureScript thinks the ({:user ...} ...)
is a function call and tries to evaluate it. I can put list
in there and it receives it fine but Om Next isn't happy. I somehow need to quote the ()
s but still allow CLJS to evaluate their content.
Well, if I write it by hand - in CLJS -, I'd backtick quote it so it treats ()
as a list.
please show me two pieces of code, in that gist, hand-written code and code produced by your macro
With unquoting to evaluate the function call. Or maybe even <backtick>[(~{:user ...} ...)]
Now, that's something I can't easily do in code that I generate in Clojure for ClojureScript, right?
@jannis: FWIW, syntax-quoting is nestable
(defmacro foo [bar]
`(identity `({:user ~~bar})))
boot.user=> (def x 42)
#'boot.user/x
boot.user=> (foo x)
({:user 42})
@anmonteiro: I've been thinking about whether I can double-quote there. I didn't know how though. I'll give it a shot.
@jannis: double-quote and double-unquote :) ~~
looks funky
I think the question boils down to: do you know the value of that tilda-sub-expression at compile time? if yes, why not simply generating that data as quoted thing
it has to be done at runtime
it’s the result of CLJS evaluation
so runtime
@jannis: you can always avoid the double-quoting thing by calling (list foo)
there must be some other “outer” macro in play, because then I don’t understand why building the data via (vector (list ((subexpr-call) …)) wouldn’t work
it does expect a list after the vector
@anmonteiro: (defmacro foo [] (list :foo :bar))
- would that return a list to ClojureScript or an expression where it tries to call :foo
?
expression to be evaluated
I meant
(defmacro foo []
`(list :foo :bar))
Right. That's what @darwin suggested earlier. For some reason Om Next wasn't happy with it, thinking (list :foo :bar)
is a mutation, not a query (at least @anmonteiro knows what these terms mean ;))
could it be a bug in some other part of the app?
it really does look like a valid thing to me
feel free to ping me if you’re still stuck
@anmonteiro: Thanks 🙂