This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-10-28
Channels
- # aws (3)
- # beginners (14)
- # boot (222)
- # cider (9)
- # cljs-dev (14)
- # clojure (107)
- # clojure-chicago (1)
- # clojure-dev (31)
- # clojure-nl (1)
- # clojure-poland (3)
- # clojure-russia (44)
- # clojure-sg (13)
- # clojure-za (3)
- # clojurescript (81)
- # core-async (5)
- # core-logic (4)
- # cursive (3)
- # data-science (3)
- # datomic (13)
- # events (7)
- # ldnclj (6)
- # leiningen (1)
- # off-topic (4)
- # om (298)
- # re-frame (13)
- # ring-swagger (7)
- # yada (12)
in ClojureScript, shouldn't a (instance? js/Error error) succeed on a js/ReferenceError?
ok I tried in my repl... it does, sorry for the noise
Working on inf-clojure eldoc support and ran into a problem when using a ClojureScript repl. Currently something like (:arglists (clojure.core/meta (clojure.core/resolve <some var>)))
is used to get the arguments of a fn. Anyone have an idea what the best way is to do this in ClojureScript since it doesn't have resolve
.
@otijhuis: clojurescript does not have vars.
@ordnungswidrig: I know. Just need a way to get the argument lists of a fn (even when the symbol has a ns alias like s/join
)
@bensu: Didn’t work with https://github.com/suprematic/khroma
@otijhuis: oh, I see.
@ricardo: I'm sorry! that's because khroma doen't specify :cljsbuild
in its project.clj
. How do you build it? I couldn't find any scripts there either
@bensu: That explains that. No build yet, just pushed to Clojars and included on others.
for peolpe who are getting
{:error #error {:message "Could not require something.ns", :data {:tag :cljs/analysis-error}, :cause #object[Error Error: Namespace "cljs.user" already declared.]}}))
here is a solution for you, that would have saved a lot of debugging time to me:
(set! js/COMPILED true)
-> https://github.com/LightTable/Clojure/pull/28Hi guys - I’m creating an app using electron. Is there a way I can have 2 figwheel instances - one for the frontend and one for the backend? It’s painful having to restart the app every time I make changes.
then in the repl you can switch between them; example commands are printed at startup
@bhagany: Thanks! I’ve moved beyond, but into another problem. Hopefully I’ll be able to fix that and use it exactly like I think I want!
I'm struggling to translate the following to cljs
function parse(spec) {
vg.parse.spec(spec, function(chart) { chart({el:"#vis"}).update(); });
}
what have you got so far?
try a fn?
(fn [chart] …)
also i dont think it should be .vg
since thats the root obj...
Hi guys, I'm new to clojurescript. I'm using counterclockwise and figwheel ( command: lein figwheel ) to run the web page. I was wandering if I can use the debugger while running stuff with figwheel? Thanks!
you might be able to do vg.parse.spec.
directly
@bojanx100: you mean the browser debugger? or Eclipse debugger?
eclipse debugger, for clojure code. If I can get a clojure debugger in chrome that would work as well... I know how to get eclipse debugger without figwheel, i just run the the code as a clojure application and then run the server in repl, but figwheel does that for me.
mmm....the eclipse debugger is still an experimental feature..I don't think there is something like that at the moment but you can open an issue request and @laurentpetit will answer it 😄
@bojanx100: the debugger of eclipse cannot debug clojurescript code, no
@otijhuis: at the moment a bunch of cljs tools have their own copy of resolve, this is mine (in a cljs file, see also repl.cljs in mfikes/planck):
:require [cljs.analyzer :as ana])
(defn resolve
"From cljs.analizer.api.clj. Given an analysis environment resolve a
var. Analogous to clojure.core/resolve"
[env sym]
{:pre [(map? env) (symbol? sym)]}
(try
(ana/resolve-var env sym
(ana/confirm-var-exists-throw))
(catch :default _
(ana/resolve-macro-var env sym))))
@richiardiandrea: thanks a lot! I'll look at planck as well then
Hey, we are trying to use the cljs testing system with phantomjs. We would like to exit nonzero if any tests fail. The recommended approach:
(defmethod report [:cljs.test/default :end-run-tests] [m]
(println "\nYO!!!Ran" (: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))))
fails if there are any async tests. In fact, it isn't clear how to get any results when there are async tests.
basically I believe that :end-run-tests is not called if there are asynchronous tests.We are using phantomjs and the doo dev said the test runner is not obvious so that could be a possibility.
you have to use a defmethod
, let me get the link for you
or use doo
, which is very cool
lol sorry i was reading the text
i guess you've seen this: https://github.com/clojure/clojurescript/wiki/Testing#async-testing
@chrisn: consider using the cljs.test/successful?
function to the determine the exit code. It's part of the testing api
right, my contention is that :end-run-tests isn't getting called at all when there is more than one async test.
i see @bensu is writing so I will let him answer because he's got more experience 😄
the problem is probably that you are exiting the phantom script before the :end-run-tests
gets run
(ns style.test
(:require [cljs.test :refer-macros [run-all-tests run-tests deftest is async run-tests testing] :refer [report]]
[style.test.event-test]))
(enable-console-print!)
(defmethod report [:cljs.test/default :begin-test-ns] [m]
(println "\nTesting with Karma" (name (:ns m))))
(defmethod report [:cljs.test/default :end-run-tests] [m]
(println "\nYO!!!Ran" (: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))))
(deftest foo
(is (= 1 1)))
(defn ^:export run
[]
(run-tests
'style.test
'style.test.event-test
))
Yep, it looks like you have solved this well in doo, I think that is the right answer rather than re-deriving it here.
for the record, read this https://github.com/bensu/doo/blob/master/library/resources/runners/headless.js#L85
right, so you need to set a hook from the script, which then gets called from :end-run-tests
Yep, I see now. You can't just call exit but have to chill and handle it when it happens. In any case, I will look into using doo as I am sure there are other things that will trip us up.
btw, I found very complicated to create a phantom repl, looking at cljsbuild
advanced examples. I could not make it work.
@bensu have you considered implementing that in doo
automagically?
phantom is there to replicate a browser's behavior under scripting, if I need to use a repl why can't I just use the browser's one?
yep but there can be differences, like the one I found this morning
maybe only slimer is 1:1
but it is just an idea
that's true