This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-06
Channels
- # adventofcode (24)
- # aleph (1)
- # bangalore-clj (2)
- # beginners (196)
- # boot (148)
- # cider (18)
- # clara (83)
- # cljsrn (24)
- # clojure (210)
- # clojure-brasil (3)
- # clojure-china (1)
- # clojure-italy (11)
- # clojure-korea (8)
- # clojure-russia (82)
- # clojure-spec (115)
- # clojure-uk (130)
- # clojurescript (109)
- # core-async (7)
- # cryogen (1)
- # cursive (22)
- # datascript (11)
- # datomic (6)
- # devcards (2)
- # emacs (1)
- # garden (1)
- # hoplon (2)
- # incanter (1)
- # klipse (4)
- # luminus (4)
- # off-topic (89)
- # om (53)
- # onyx (78)
- # parinfer (9)
- # proton (3)
- # protorepl (20)
- # re-frame (107)
- # reagent (52)
- # rum (30)
- # spacemacs (1)
- # testing (3)
- # untangled (31)
- # vim (43)
- # yada (9)
Anyone have an idea on best practices for running tests in a cljs repl (using Boot)? Got a basic skeleton going but it’s not working. My test runner:
(ns wordroot.test
(:require
[cljs.test :refer-macros [run-all-tests]]))
(defn run-frontend-tests
[]
(run-all-tests #”^wordroot.*-test$”))
How I attempt to execute it at the repl:
(ns cljs.user
(:use [wordroot.test :only [run-frontend-tests]]))
(run-frontend-tests)
Update: Including the namespace in my core.cljs file fixes the issue of the namespaces not being included
What is the difference between clojure.core/instance?
and cljs.core/implements?
?
Obviously there are differences between the Java and JS versions of things we're working with. I'm mostly curious why they have to be named differently.
@stevechan: In cljs we generally use immutable maps: {:aaa 111, :bbb 222, :ccc 333}
. If you really need a mutable JavaScript object type, you can use #js {:aaa 111, ...}
looks like
#js {:showDropdowns true,
:showWeekNumbers true,
:opens "right",
:buttonClasses #js ["btn btn- ......
...
Note that you can also write a Clojure data structure (same thing without the #js
's) and then call clj->js
on the whole thing, which recursively transforms all maps into objects and all vectors into arrays
You can call aaa
method by calling (.aaa my-obj my-args)
How to write it by cljs ? for document.getElementsByClassName("applyBtn")[1].onclick = function(){alert(111)}
@chooie to run tests you must require all namespaces that include tests as well not just cljs.test
@aengelberg you should avoid implements?
it’s a perf thing only to avoid the bottleneck in satisfies?
to answer your question, there are no interfaces in JS, so instance?
can’t be used to test for protocol membership
Can anyone see why my conformer does not work?
(defn valid-money? [x]
(let [res (cond-> x
(string? x) money/string->number)]
(if (money/nan? res)
:clojure.spec/invalid
res)))
(s/def :sale.line/amount (s/conformer valid-money?))
(s/def :sale.line/description (s/and string? #(re-matches #".+" %)))
(s/def :sale/line (s/keys :req [:sale.line/amount
:sale.line/description]))
(s/conform :sale/line {:sale.line/amount "wrong"
:sale.line/description "foo”}) => {:sale.line/amount :clojure.spec/invalid, :sale.line/description "foo"}
spec does not seem to care that I return :clojure.spec/invalidOmg it has to be cljs.spec/invalid
@mitchelkuijpers use ::s/invalid
, just to be safe 😉
Ow lol
That would be a better solution
@thheller Thank you that works like a charm
(was already seeing himself adding clj and cljs reader conditionals)
can someone tell me how is this documentation? http://blog.ducky.io/reagent-docs/0.6.0-alpha2/reagent.core.html#var-render-component
not that it makes a difference, seems like i get one answer a month from the clojure community, otherwise i am completely ignored
what is a "frontend production env" ?
From https://github.com/Unitech/pm2: >"PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks."
@dacopare the word that confuses me there is "frontend" which that page does not mention
I mean, node.js on the frontend in production - does that imply running a cluster on the client machine or what?
I know what a load balancer is, and I'm familiar with node, but a load balanced node frontend I don't get
if the question is whether pm2 is useful when using cljs as a backend on node, I'd make a wild guess that it would be as useful as it would be with js
(js/eval “window.alert(‘eval is evil’)”)
-wild ass guess-
Is anyone else here using Petrol? https://github.com/krisajenkins/petrol We use it in one of our projects. Hasn't seen any commits since January.
Perhaps I should raise my hand for this question. 🙂
Heh! Hi!
Hi! 🙂
Petrol is the distillation of the approach I'd used with ClojureScript apps for the couple of years prior to releasing that library. My main aim was to crystallise the pattern, so I could describe it at ClojureX 2015.
I still believe in the approach, and it’s how I’d tackle a ClojureScript project if I were starting one today.
But...
I haven’t had any ClojureScript gigs this year. So that’s why there’s been no activity on it. 😞
Thanks for explaining that. Saw open PRs, issues, and no commits since January so I figured I'd ask. I'm just getting up to speed with it now. Seems similar to an approach I was originally pushing for, which was to use CQRS on the front-end. I like the similarities and the extra structure the library provides, was just concerned about the longer term maintenance.
I'll keep my ears to the ground for anyone looking for a hired gun @krisajenkins
My best advice would be to take the pattern and make it your own. (That’s what I did for 2 years before it got a name.) It’s really only about 120 lines I think. It’s more idea than codebase. 🙂
The ideas were presented here, if you’re interested: https://skillsmatter.com/skillscasts/7227-clojurescript-architecting-for-scale
And, thank you. 😉
Sounds good, thanks Kris! I've posted in the Den of Clojure (Denver user group) Slack to see if anyone is looking for a contractor.
Aw, thanks. 🙂
soooo I have tried this before but in the past I believe it was not possible: is there a way to get the current namespace in CLJS?
@ddellacosta no - no namespace or var hijinks are possible in non-bootstrapped ClojureScript
right, thanks @dnolen
@borkdude: no. Only if
1. A :file-min
is specified (which I assume it is in your case)
And 2. You're compiling with :simple
or :advanced
hi there 🙂 is there a good channel for clojurescript noobs?
@goomba: #beginners is a great place to ask any type of question, Clojure or ClojureScript
great, thank you 🙂
Has anyone tried using core.async to handle “catastrophic backtracking” in a regular expression? This is particularly problematic in JavaScript where regular expression calls may never return, thus locking up a Go block completely. I’m having trouble extracting a value from the Go block or timing out, and I suspect it’s because the Go block can’t release control.
This is notably not a problem on the JVM, the rub is because of JS’s single threading.
To be more specific, after launching a Go block that will execute a catastrophically bad regex evaluation, other Go blocks cannot start.
@michaeldrogalis there isn’t a solution to that problem since it doesn’t have anything to do with core.async
@dnolen That makes sense, thanks for verifying. 🙂
@michaeldrogalis I agree there's probably not much you can do for a catastrophic regex, but @viebel detects something like this in Klipse, not sure how he does it, or under which circumstances it is applicable.
@danielcompton Attempting to stuff it into a web worker or some such. 😕 It’s not a particularly fun problem.
Google Closure Compiler now available in pure JavaScript: https://developers.googleblog.com/2016/08/closure-compiler-in-javascript.html
https://github.com/viebel/klipse/pull/131 is how he does it
basically there are two pieces to it
1) a go-block that periodically wakes up every N milliseconds and updates a “this is the last time i woke up” atom, and
2) the JS that klipse emits includes a bunch of calls to guard
, which checks to see if the “this is the last time i woke up” atom hasn’t been updated in a long time, and throws an exception (killing the currently executing function) if so
the idea is that if you’ve got an infinite loop, it’ll block the “watchdog” go-block from running and trigger the guard
bailout; https://github.com/viebel/klipse/pull/131/files#diff-b818e251587635f1ae83246d9765c30d is the relevant code
again i don’t know if this approach makes sense in any other context but this one, i don’t think most people will want to write+use modified versions of cljs.compiler/emits
What is the best way to debug cljs-ajax calls? I am getting a very non-informative error from the server. Is there a way to see the actual request being made?
@jrheard Interesting. Thanks for the pointer, Ill dig into this patch.
@dnolen Thanks, got the request now. Works when pasted into the browser, but still fails when called from code.
@mac try goog.net.XhrIo
instead. I avoid 3rd party libs for requests - less to deal with