Fork me on GitHub
#clojurescript
<
2015-10-28
>
richiardiandrea01:10:56

in ClojureScript, shouldn't a (instance? js/Error error) succeed on a js/ReferenceError?

richiardiandrea01:10:49

ok I tried in my repl... it does, sorry for the noise

kamn03:10:48

@bensu: Very cool app

otijhuis10:10:28

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.

ordnungswidrig10:10:47

@otijhuis: clojurescript does not have vars.

otijhuis10:10:39

@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)

bensu13:10:48

@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

ricardo13:10:31

@bensu: That explains that. No build yet, just pushed to Clojars and included on others.

richiardiandrea15:10:59

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/28

jaju16:10:06

Hi 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.

bhagany16:10:56

@jaju - yep, you just do something like lein figwheel build-1 build-2

bhagany16:10:23

then in the repl you can switch between them; example commands are printed at startup

jaju16:10:40

Ah - let me try that and check!

jaju16:10:52

@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! simple_smile

bhagany16:10:09

@jaju: good to hear, good luck!

aaelony17:10:37

I'm struggling to translate the following to cljs

function parse(spec) {
  vg.parse.spec(spec, function(chart) { chart({el:"#vis"}).update(); });
}

aaelony17:10:03

particularly the function(chart ... part

aaelony17:10:54

any help appreciated simple_smile

adambrosio17:10:08

what have you got so far?

aaelony17:10:56

not much... (defn parse [spec] (.spec (.parse (.vg spec ???

adambrosio17:10:55

(fn [chart] …)

aaelony17:10:25

of course. thanks..

aaelony17:10:38

much appreciated

adambrosio17:10:24

also i dont think it should be .vg

adambrosio17:10:33

since thats the root obj...

bojanx10017:10:44

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!

adambrosio18:10:15

you might be able to do vg.parse.spec. directly

aaelony18:10:18

@adambros: yeah, I need to circle back and first understand the js better

richiardiandrea18:10:14

@bojanx100: you mean the browser debugger? or Eclipse debugger?

bojanx10018:10:40

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.

richiardiandrea18:10:04

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 😄

laurentpetit18:10:55

@bojanx100: the debugger of eclipse cannot debug clojurescript code, no

ace19:10:30

Clojurescript isn’t the easiest to debug for sure

richiardiandrea22:10:34

@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))))

otijhuis22:10:42

@richiardiandrea: thanks a lot! I'll look at planck as well then

chrisn22:10:26

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.

chrisn22:10:07

We are using phantomjs and the doo dev said the test runner is not obvious so that could be a possibility.

richiardiandrea22:10:16

you have to use a defmethod, let me get the link for you

richiardiandrea22:10:26

or use doo, which is very cool

chrisn22:10:33

I posted a defmethod...

richiardiandrea22:10:04

lol sorry i was reading the text

bensu22:10:32

@chrisn: consider using the cljs.test/successful? function to the determine the exit code. It's part of the testing api

chrisn22:10:50

right, my contention is that :end-run-tests isn't getting called at all when there is more than one async test.

richiardiandrea22:10:56

i see @bensu is writing so I will let him answer because he's got more experience 😄

chrisn22:10:09

We also lose end of run reporting.

bensu22:10:19

can you post your script?

bensu22:10:57

the problem is probably that you are exiting the phantom script before the :end-run-tests gets run

chrisn22:10:10

(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
   ))

chrisn22:10:21

Yes, @bensu that sounds very likely.

bensu22:10:27

next time try a paste service simple_smile

chrisn22:10:37

yes sir:).

bensu22:10:37

I meant the phantom script

bensu22:10:54

yeah, that's not going to cut it for async.

chrisn22:10:12

Yep, it looks like you have solved this well in doo, I think that is the right answer rather than re-deriving it here.

chrisn22:10:41

Yep, I was just looking there.

bensu22:10:10

right, so you need to set a hook from the script, which then gets called from :end-run-tests

bensu22:10:19

javascript was not made for async and it shows

bensu22:10:38

but that's the way the cookie crumbles

chrisn22:10:40

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.

bensu22:10:44

there a couple of things around core.async as well

bensu22:10:51

in any case, feel free to ask

richiardiandrea22:10:25

btw, I found very complicated to create a phantom repl, looking at cljsbuild advanced examples. I could not make it work.

richiardiandrea22:10:39

@bensu have you considered implementing that in doo automagically?

bensu22:10:10

I don't see the point.

bensu22:10:51

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?

chrisn22:10:30

debugging tests may well be one.

richiardiandrea22:10:41

yep but there can be differences, like the one I found this morning

richiardiandrea22:10:50

maybe only slimer is 1:1

richiardiandrea22:10:10

but it is just an idea

bensu22:10:59

sure, there are reasons, I meant that it's a major undertaking with few usecases.

bensu22:10:38

I'll gladly help anybody that wants to try, but wouldn't recommend it. It's not only a somewhat fragile platform it's also completely meant for scripting, which will probably make an interactive process challenging