This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-14
Channels
- # admin-announcements (17)
- # announcements (4)
- # beginners (47)
- # boot (347)
- # braid-chat (55)
- # bristol-clojurians (5)
- # cider (5)
- # cljs-dev (1)
- # clojure (111)
- # clojure-chicago (1)
- # clojure-russia (73)
- # clojure-ukraine (2)
- # clojurescript (162)
- # code-reviews (1)
- # community-development (199)
- # core-matrix (2)
- # cursive (29)
- # datomic (40)
- # devcards (13)
- # dirac (37)
- # docs (12)
- # editors-rus (2)
- # emacs (11)
- # events (26)
- # hoplon (2)
- # jobs (8)
- # ldnclj (31)
- # lein-figwheel (2)
- # off-topic (7)
- # om (59)
- # other-lisps (1)
- # portland-or (1)
- # proton (50)
- # re-frame (5)
- # reagent (13)
- # ring-swagger (5)
- # spacemacs (3)
- # yada (3)
Anyway, what you think is the intention could've been done like this:
(case backend
#?@(:clj (:eval eval/compile))
:base base/compile)
That's just a guess; but I could imagine this being interpreted as two tags applied to the same form
I'm more curious what the original code intended, though I guess "use eval/compile
only in Clojure" makes sense
And that what leads me to the interpretation that cljx would treat is as two tags applied to single form, since this could must have worked in Clojure at least if no-one noticed this issue.
I guess this is popular question for CLJS, however I didn't found good answer in the web. Q: Let's suppose we have large working javascript react application (in my case it also use ES6 syntax), have anybody found the way how start integrate CLJS there and replace js react-components with clojurescript alternatives gradually. p.s. Could it be a good solution - to move all react components to external library and starting actively using js/interop and wrap then somehow. Thanks!
Is there much in the way of DOM/CSS animation libraries for CLJS? I am found Quill, but it uses the Canvas, so I'm not sure if it's appropriate for day-to-day web apps. I suppose I could do some JS interop with something like Velocity.JS as well.
Here's the reference: https://gist.github.com/cstorey/9198985
@darwin considerable excitement here about Dirac. No problems so far
@jaredly: sure, catch - https://github.com/jarohen/bounce
The books ClojureScript Unraveled and Modern ClojureScript have been mentioned. Would one of them be a good starting point for someone completely new to Clojure (and functional programming), for reading in a weekend?
Hi, Boris. Keep in mind that ClojureScript is a dialect of Clojure and since you mentioned being new to Clojure and functional programming you might be better off with a Clojure book as there are more of them to choose from.
@slotkenov: if completely new to Clojure I suggest a Clojure book first.
Or if you like more fun books like "_why's poginant guide to Ruby" or "Learn you a Haskell for Great Good" then maybe "Clojure for the Brave and True" will be more appropriate.
I've started out with the first ("Programming Clojure" that is). I already knew functional programming basics when I did, but I think their introduction to FP is good enough even if you know nothing about it.
a little bit off-topic maybe, but how do you read those books? you sit at your table with the book opened and type the sample code or read it on your commute?
@slotkenov: I agree with @jaen . I would read in parallel Programming Clojure and Clojure for the Brave and True. Then one of the cited cljs tutorials. Then….well, SICP, even if it does not cover the co-recursion (which it’s typical in CLJ/CLJS), IMHO, it’s still the best computer programming book ever
Racket's How to Design Programs is also pretty cool if we're talking generic CS introductions.
@aurelian: depends on your learning habits. Programming is a kind of constructive activity, so it means that the more you type the best it is
I'm reading Applied Clojure on kindle while commuting and Joy of Clojure on my laptop typing stuff in repl
@slotkenov: I heard that Rich said that SICP is not so fundamental for CLJ/CLJS programmers. Perhaps this is the only Rich’s opinion I do not agree with (if it’s true).
@aurelian: yep Applied Clojure it’s a very good book as well. that said I learned LISP on a LISP machines, which means by reading code from the others. The more code you read, the best you write
@aurelian: it entirely depends, but I learned C by reading K&R through twice and then I just knew enough to start hacking on things to solidify that. But that was one of my first programming languages. With Clojure I started on the other end - I just started hacking on something and I used those books as references (since I already knew FP basics from playing with Haskell).
I usually don't buy books about programming languages or frameworks, Clojure is an exception because is my first contact with FP stuff
But for Ruby? I've found that wast of time if I can just online tutorial through it (yes, that's "online tutorial" used as a verb).
"Haskell Programming from First Principles" is probably the next time I will buy a CS-related book, but first I need to finally find time to learn Haskell properly ; d
And using Clojure kind of pushes that further into the future, because I can do pretty nice FP right now (sans types, sadly) and not after I grok all them typeclasses.
As for SICP not being fundamental to Clojure programmers - well, I can kind of agree with that in a way - Clojure is not meant to be a first language in the way Scheme or Racket are. SICP is a great foundational book, but Clojure sort of assumes you're past that level and things like abstraction are natural words in your dictionary.
But that's also something that's discouraging - a friend wants to learn programming and I wanted to teach her using Clojure because functional paradigm is a better introduction to programming than imperative and just imagine how awesome would be to use Clojurescript and boot-reload to have some of that Bret Victor-ish immediate feedback capability. But then you're reminded that Clojure doesn't care about first timers much with it's stacktraces, bad error messages and general spots of roughness and you just decide to use Racket and "How to Design Programs" : V
@mikethompson: thanks!
Hey guys: I am trying to write async tests for my project but the tests fail even after i follow the example listed here https://github.com/clojure/clojurescript/wiki/Testing This is how my test looks:
(deftest test-async-function
(testing "Async Test"
(println "[debug] - about to async test")
(async pass
(go
(is (= (<! (http/get ""))
:true))
(pass)))))
Any suggestions on what I can do to get this working will be greatly appreciated@dnolen @mfikes I documented Remote REPL configuration https://github.com/clojure/clojurescript/wiki/Remote-REPL (feedback appreciated)
@geoffreymuchai: I think async should be the top level form in deftest
, so first wrap with async
then with deftest
oh… ok… lemme give it a try
that doesn’t work unfortunately @nberger
You now have:
(deftest test-async-function
(async pass
(testing "Async test"
(println ...)
(go
(is ....)
(pass)))))
right?how is it that "it doesn't work"? it doesn't show a test failure? a simple non-async test works, I mean it shows failures?
that is what i have and…. this is the output
"Tests failed!" is promising! If you remove the assertion entirely, it stops showing "Tests failed!"?
actually… i have posted the wrong output… lemme run the test again real quick
it doesn’t print anything within the go block
wait… it does… my apologies
lemme remove the assertion
the test still fails with the same error… this is how the test looks
you can try with something simpler like:
(go
(<! (async/timeout 100))
(is false)
(pass))
(deftest test-async-block
(async pass
(testing "Async Test"
(println "[debug] - about to async test")
(go
(pass)))))
(simpler in that it's more directly clear what's happening, and you can change the false
for a true
to make it pass)
It doesn’t run any other tests in the namespace the async tests are but when i remove it, they work
Ok... something similar happened to me where the test runner didn't properly wait for the tests to finish... in a way that it worked for sync tests, but not with async tests... what are you using as runner? doo or something ad-hoc?
I had part of my runner writing the test report into a div with some id, and then another part of the runner inspecting that div content... but it didn't wait for it to exist
we have created something ad-hoc using cljs.test
we haven’t done anything fancy on our code base… we use the testing library available in cljs i.e. cljs.test
Ok... you probably write the test report to somewhere in something like (defmethod cljs.test/report [:cljs.test/default :end-run-tests] ...)
?
you have to look into that runner... we can't be sure if it is properly implemented for async tests
ok… let me confirm
@nberger: our report code looks like this:
(defmethod report [::test/default :summary] [m]
(println "\nRan" (:test m) "tests containing"
(+ (:pass m) (:fail m) (:error m)) "assertions.")
(println (:fail m) "failures," (:error m) "errors.")
(aset js/window "test-failures" (+ (:fail m) (:error m))))
and then you have something else checking the content of "#test-failures" and it prints "Tests failed" if it doesn't have 0
as its content?
Ok, what's happening is that test-failures is empty, because tests haven't finished yet... the code that's checking "#test-failures" content, it should wait until there's a number there
We have a similar setup in a project, and we use selenium (through clj-webdriver), so we have this before checking our "#test-results":
(taxi/wait-until #(taxi/exists? "#test-results") (* 10 1000))
(it waits at most 10 seconds for it to appear)that explains why the tests don’t continue running once it hits the async block
nice… thanks @nberger for this useful insight. Much appreciated
lemme refactor our runner to better support async tests
You can also try switching to https://github.com/bensu/doo, it handles this for sure
ok… will review it to determine what works best
@geoffreymuchai: look at http://funcool.github.io/clojurescript-unraveled/#unit-testing for reference on how to set up a basic runner
@slotkenov: I’d imagine you just set up the sass compiler same as any project. are there any particular issues you’re running into?
ah, lein-shell may be what you need: https://github.com/hyPiRion/lein-shell/blob/stable/doc/DOCUMENTATION.md#as-a-preparation-task
then just use that to do the sass thing
@slotkenov: there's also https://github.com/Deraen/sass4clj
@slotkenov: if you decided to use boot I suggest https://github.com/jgdavey/boot-middleman - you then have the whole middleman at your disposal.
The minor difference is (if it counts in your case) sass4clj uses jsass (Java port of Sass compiler) while boot-middleman uses the original Ruby compiler through JRuby.
Not exactly. Jsass is JNA wrapper for Libsass which is the official(?) C implementation of Sass, though it doesn't support all features of Ruby Sass.
Which means that Jsass contains compiled native libs for multiple operating systems and only the linux libs have been automatically tested, so it's possible that it's not very reliable on OS X or Windows.
Right, my bad; still not 100% Ruby Sass, though. When I tried libsass last time it didn't compile to the exact same CSS Ruby Sass would, so that's why I mention it. Maybe it had been improved by now.
@slotkenov: It's not a Ruby dependency, it runs inside JVM on JRuby. No need to have Ruby installed.
So if you don't need other things middleman offer then sure (I for example liked it because you can take a middleman project from designers as-is, plug it into boot-middleman and then use kioo for templates), libsass is probably a better choice.
So if you ever need to work with external designers that don't know hiccup it might be a nice option.
OK interesting. I work with an external designer now. She doesn't create any html though
@juhoteperi: that description of Jsass fills me with dread.
@juhoteperi: I thought libsass was now in sync feature wise with RubySass. ?
I dunno, I like my Sass. I can just use Bootstrap or something and don't care about styling.
I hear Compass needs Ruby sass
Yeah, all this - https://github.com/Compass/compass/tree/stable/core/lib/compass/core/sass_extensions - requires declare
method for functions - http://sass-lang.com/documentation/Sass/Script/Functions.html#declare-class_method
So it maybe only makes sense for legacy projects to be hung up on this requirement. I always preferred bourbon anyway, but at some point Sass port of bootstrap required compass
which kept me from migrating to libsass.
There's also a SASS watcher for figwheel - I've not used it but it might work as well. https://github.com/bhauman/lein-figwheel/wiki/SASS-watcher
@slotkenov: we use inline-styles all the way with good results
I'm getting a bunch of WARNING: Use of undeclared Var foo/bar
, and I'm trying to track them down. Is there a way to get the compiler to point you to the site where the var is used?
It should make the compiler say what namespace it's analysing (among other things) so it will make it easier for you to track it down.
Which HTTP/clojurescript libraries are currently most solid/used/respected, IYO? I'm new to clojurescript, building a HTTPS pipeline where one record leads to another, many stages deep, leaning towards using core.async. Tried cljs-http but it's not working (cross scripting issues) and I'm not committed to it yet.
XSS will be a problem no matter what lib you use, I'd expect
Could someone help me understand what the warning "Required namespace not provided for…" means?
@grav Sounds like a good match in combination with react components actually. Using plain old CSS then? In there a way to keep the styles isolated per component, to avoid naming conflicts?
@slotkenov: you mean class name-naming conflicts? we don’t use css classes at all ...
I don't know how manageable that is, but some people seem to swear by it to the point of making whole libraries - https://github.com/FormidableLabs/radium