This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-13
Channels
- # beginners (50)
- # boot (27)
- # bristol-clojurians (7)
- # cider (30)
- # clara (1)
- # cljs-dev (130)
- # cljsrn (14)
- # clojure (179)
- # clojure-austin (6)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-spec (19)
- # clojure-uk (54)
- # clojurescript (64)
- # core-async (3)
- # data-science (1)
- # datomic (66)
- # duct (11)
- # emacs (5)
- # figwheel (1)
- # fulcro (26)
- # funcool (7)
- # jobs (1)
- # jvm (6)
- # keechma (5)
- # lein-figwheel (5)
- # luminus (5)
- # lumo (1)
- # off-topic (93)
- # parinfer (37)
- # pedestal (15)
- # protorepl (10)
- # re-frame (42)
- # reagent (12)
- # shadow-cljs (71)
- # spacemacs (3)
- # specter (7)
- # vim (8)
- # yada (9)
Crazy new capability is now in ClojureScript master for running stuff via a new cljs.main
. As an example
echo "(defn square [x] (* x x)) (prn (square 3))" | clojure -Sdeps '{:deps {org.clojure/clojurescript {:git/url "" :sha "82998109292c5982380e945e7565d7425879e0f3"}}}' -m cljs.main -js rhino -e '(* 4 (Math/atan 1))' -
prints out
3.141592653589793
9
This example is a bit complicated, but at its core is command line processing capability built directly into ClojureScript (things like -e
to eval, -m
to specify a main namespace, etc., essentially the same kind of stuff you can do with the Clojure REPL and clj
.)Much simpler usage, using the uberjar, might look like
java -jar cljs.jar -e 3.14 -r
to evaluate a form and start a REPL
or
java -jar cljs.jar foo.cljs
to run a file.Reagent is the most widely used one, if that’s what you are asking for
Yes, I think so, thanks! I have experimented with Reagent a bit some time ago, just wanted to check that it’s still a good way to go.
If it will be bigger app you can take a look at re-frame. if You dont want use re-frame You can read doc of re-frame and take some ideas from it.
tonsky's rum is very good too. I have used both extensively, and i think rum is a little better.
@U56PV2X9T how do You manage state in rum? Does rum have something similar to re-frame/redux/mobx ?
I have used this model for other things too like asychronus communication through sockets with npm
Hi all, I’m taking a huge leap after convincing the CTO to let our team start using Clojure and Clojurescript. The first challenge will be integrating existing CSS into our new project. It’s a Re-frame app, but needs a bunch of CSS from an NPM less/sass project to render correctly. I’ve never worked with css pipelines, and I’ve just used gulp and webpack a bit. Where should I start?
I’m using lein sassc
to compile my CSS files from Sass files, but really, anything that builds your CSS and puts it in the right place will work. There’s not really anything that’s necessarily cljs-specific about the CSS part.
That makes sense. But what about getting those files out of the current repo? Without just pulling out the generated css?
I’m not sure I’m understanding the question, but I have a .gitignore
file that excludes the generated css from being included in the repository. I put the sass files in the repo, since they’re part of my project. If yours are generated externally, I’d just something like gulp to push them from the other project, thought that would be somewhat fragile, since you could mess it up if your directory structure changed.
I haven’t done much in the way of mixed cljs/npm projects, maybe someone else would have some advice more appropriate for your situation.
That’s exactly right, @manutter51 I need css from a separate npm project included into mine, without being too fragile.
I’ve never done that, but I did find an npm plugin for leiningen. https://github.com/RyanMcG/lein-npm. I’ve never used it, so I can’t say if it’s good or bad, but you might want to look at it.
Is there any reason that it should be a problem to have js/require
in the expansion of a macro?
I'm still checking that I haven't done something else stupid, and my env is complex (react-native and figwheel and ...) but it seems that I get a strange error (the stack trace includes figwheel internals) if I do this unless I have previously called js/require on the same module from my .cljs code.
Hello, I was wondering if anyone had tackled creating a virtual dom + diffing algorithm w/ data binding to components.. similar to React?
@frostjust there’s quite a few libs using react, but none in cljs that replace react afaik
@noisesmith Thanks, yeah I was looking for something in pure cljs.
I wouldn’t expect a cljs solution to that to be very “pure” anyway - most of the code would be interop with the built in DOM apis
(or so I’d assume…)
Yeah, depending on how it chose to interact with the DOM..
it would be a fascinating exercise, but I don’t know if there’s be a pragmatic benefit
@frostjust I implemented a couple vdom things for testing but you really don't gain that much. the good thing about react is the ecosystem and having access to a lot of components. anything custom loses that.
It would be nice to have something lightweight. Also having something like jsx in clojure would be interesting.. although I guess there's already hiccup.
clojurescript’s reader isn’t meant to be that extensible, so you’d need a custom pre-processor
unless you use something that is effectively hiccup, using valid data literals that is
Haha pre-processor hell was one of the aspects of js I was trying to escape by coming over to clojure
:thumbsup:
hiccup, atoms, and specter are worth the price of admission to clojurescript in my opinion
Yeah, I'll take it. I think I just need to get out of the js mindset. :male_zombie:
Anyone know how to setup a test runner with async tests for cljs? The following results in an incorrect error code:
(defmethod report [:cljs.test/default :end-run-tests] [m]
(when-not (successful? m)
(throw :error)))
In order to get it working I need to do:
(defmethod report [:cljs.test/default :end-run-tests] [m]
(when-not (successful? m)
(js/setTimeout #(throw :error) 0))
Because it runs other tests or something after the test fails.I’m not quite sure what you are trying to accomplish but have you taken a look at https://cljs.github.io/api/cljs.test/async
i personally haven’t set up a test runner in cljs yet but in javascript you basically have two options: call a “done” callback or use a test runner that inspects the js event loop and waits for it to drain before determining success or failure
So I am using that and calling (done)
in my async tests. It works fine when my tests pass but when a test fails it results in tests running after :end-run-tests
which causes a 0
exit code.
so just from reading the docs, I think you’ll need to use core.async to wait for your stuff to finish before calling done
Thanks! So actually I do wait until the tests finishes before I call done. Here’s an example:
(deftest handler-on-error
(async done
(let [handler (make-handler {:cleanup-workspace identity
:upload-pdf
#(js/Promise.
(fn [resolve reject]
(reject "custom-error")))})]
(handler nil nil (fn [error body]
(is (= error "\"custom-error\""))
(is (= body nil))
(done))))))
so one of those is
tests should be failing? i can’t quite follow the code but the first is
seems correct
in other words, if you stick a (is (= true false))
before the final (done)
will it exit successfully? because that would be surprising
okay that doesn’t make any sense. sorry you’re going to have to find someone who actually understands how the system works. 😞
https://files.slack.com/files-pri/T03RZGPFR-F981E8GNL/screen_shot_2018-02-13_at_5.41.00_pm.png this is when I have the setTimeout
with (is (= true false))
And this is without setTimeout
but still the same failing test. https://files.slack.com/files-pri/T03RZGPFR-F99G8NQ30/screen_shot_2018-02-13_at_5.42.55_pm.png
@U2U78HT5G I didn't look into your test as I have not much time right now, but this is how I fixed exit status for my tests using phantomjs: https://github.com/nenadalm/Warehouse/commit/b8e746845fe28831aefe6c48a9a007283250356e#diff-88ad3ddf861b2df52fa1fa085643b6f6