Fork me on GitHub
#clojurescript
<
2016-01-19
>
jaredly03:01:16

I made a repl! https://jaredforsyth.com/reepl/ w/ auto-complete, auto-documentation, parinfer, and optional vim-mode

rburns03:01:09

@jaredly: works in chromium here, but generates this error in firefox TypeError: document.body.scrollIntoViewIfNeeded is not a function and a blank screen.

jaredly03:01:02

aha right of course

mfikes03:01:40

@jaredly: Outstanding! Neet simple_smile

kenrestivo05:01:56

in reagent, what's the difference between r/props and r/state?

kenrestivo07:01:57

hmm, nm it seems the fount of all knowledge is here: https://facebook.github.io/react/docs/component-specs.html

codemartin11:01:53

@jaredly: super cool! Sending to my lisp-curious friends

bteuber12:01:45

@jaredly: I see you privide quil bindings. Is it possible to draw stuff to the screen already?

jaredly14:01:02

@bteuber: nope not at the moment. I’ve got another setup that has repl + code editor + quil canvas

bteuber15:01:22

@jaredly: ic - looking forward to trying that one, too 😄

kul16:01:52

hi i am looking for cljs on node project setup using boot

kul16:01:02

any pointers?

jkrueger16:01:41

i’ve started work on a boot plugin to handle npm and git dependencies in boot. it’s unfinished but works in principle

jkrueger16:01:54

i’d be interested in collaborating on polishing it

kul16:01:09

nice 👍

jkrueger16:01:28

otherwise, last i checked, i couldn’t find a complete setup that works, so i opted to roll my own

kul16:01:35

but what are people using here?

jkrueger16:01:11

but that was about 6-8 months ago, so maybe the situation has improved

kul16:01:25

interesting, i am surprised there isnt anything on lein

jkrueger16:01:35

oh. sorry. i was talking about boot specifically. the lein setup is a different matter

kul16:01:46

i always see a lot of friction in setting up cljs projects, may be thats just me

kul16:01:33

https://github.com/RyanMcG/lein-npm is something i just found, but do not want to go back to lein

juhoteperi16:01:47

@jkrueger: All npm packages are available as Maven dependencies from Webjars, depending on what you need, it could be useful

kul16:01:24

interesting

juhoteperi16:01:41

Not sure if/how it works when running cljs on Node

kul16:01:58

so i can just use plane https://github.com/adzerk-oss/boot-cljs over a nodejs repl?

jkrueger16:01:38

@juhoteperi: i wasn’t aware of that. nice !

juhoteperi16:01:18

@kul: I think so. I have never tried running Cljs on Node so I'm not sure what works or doesn't.

kul16:01:41

thanks i will give it a try

kul16:01:24

like webjars is see a similar project cljsjs

peeja17:01:40

What's the best way to invoke the Chrome debugger from ClojureScript?

peeja17:01:52

(That is, insert a debugger)

dnolen17:01:34

(js-debugger)

dnolen17:01:42

it’s a macro

peeja17:01:52

Ah, perfect. Thanks!

nberger18:01:44

I'm trying to write some async tests which also use with-redefs and I'm having a pesky issue: redef'ed vars in one test are still redef'ed in the next tests. For example:

(def a 1)

(deftest async-test-1
  (async
    done
    (with-redefs [a 2]
      (is (= 2 a))
      (done))))

(deftest async-test-2
  (is (= 1 a)))

;;;; run output:

Testing foo.core-test

FAIL in (async-test-2) (:)
expected: (= 1 a)
  actual: (not (= 1 2))

nberger18:01:29

I see that this is caused by how cljs.test runs async tests, where the "next tests" run as a continuation fn which is done. So in this case they run in the with-redefs scope. So, is this just something expected?

dnolen18:01:08

@nberger: you cannot use with-redefs for async testing

dnolen18:01:15

nor binding

nberger18:01:18

yeah, I see simple_smile

nberger18:01:22

Ok, thanks

dnolen18:01:38

you can use fixtures though

nberger18:01:13

Ok, thanks again

nberger18:01:18

Found a (hacky) way to "escape the continuation":

(def a 1)

(deftest async-test-1
  (async
    _done
    (let [d (atom false)
          done #(reset! d true)]
      (js/setTimeout (fn check-done []
                        (if @d
                          (_done)
                          (js/setTimeout check-done 100)))
                      100)
      (with-redefs [a 2]
        (is (= 2 a))
        (done)))))

(deftest async-test-2
  (is (= 1 a)))
Seems like it will work for my problem at hand

nberger18:01:06

Or maybe not... simple_smile

nberger18:01:14

I mean, it works on this simple tests, but it's not that easy with actual async stuff

dnolen18:01:34

right as I said use fixtures

dnolen18:01:54

they are guaranteed to run before and after a test

nberger18:01:13

I'm dealing with some globals here... using with-redefs to kind of "mock" them. To use fixtures I'd need to change more stuff than I'd like/can change now. So, I'll try to make it work this way. Thanks anyways simple_smile

dnolen19:01:10

@nberger: you shouldn't have to change anything

dnolen19:01:31

with-redefs and binding just call set!

dnolen19:01:39

you can do the same thing in your fixture

nberger19:01:01

Hmmm yeah. Ok, I'll play with that idea

dnolen19:01:49

just store the value of the previous value in an atom or whatever

dnolen19:01:57

and restore in the :after fixture fn

nberger19:01:15

Sure, sounds like it should work. Maybe I'm dealing with something else now, I have many async requests, some of them trigger other requests, I'm still not sure if I'm stopping everything correctly before callling (done). I'll come back as soon as I have all of that more cleared out simple_smile

dnolen19:01:41

@nberger: if you have multiple async things happening in the same test you will want some kind of latch helper

dnolen19:01:47

that or you should use core.async

dnolen19:01:06

the core.async tests use the latch pattern

nberger19:01:53

What would be the latch helper? Like a signal for everything to stop? I think I have something like that, but something is escaping it. I'll take a look into the core.async tests

nberger19:01:20

Oh, I'm looking into the core.async latch helper. Interesting, thanks simple_smile

dnolen19:01:35

if you can use core.async I would just use it

dnolen19:01:54

I designed the async macro with it in mind

dnolen19:01:08

the latch thing is a bit error prone

nberger19:01:20

The style of testing that I'm doing here makes it difficult to use something like that. I'm starting my entire app, send signals which triggers the start of xhr requests, which trigger more signals, etc... let's say it's an integration test. My idea was to mock some fns that start requests and return channels, so I can put the exact messages as I want in those channels, etc... It almost works, except it doesn't simple_smile

dnolen19:01:26

I don’t really follow

dnolen19:01:38

I’ve done async tests with core.async and mocking and it works fine

dnolen19:01:50

they involve non-trivial amounts of setup too

nberger19:01:08

I'm not saying it doesn't work... well, one thing that "doesn't work" is to call the continuation fn inside of a with-redefs scope. It doesn't work in the sense that the next fns run with the redef'ed bindings, which is not what everyone expects. But that might be by design, and that's fine. The latch serves as a way to run the continuation out a scope like that, too

nberger19:01:45

And in my particular case, it might totally be the case that I have some bug or some pesky interaction which makes my tests to hang. I have to dig deeper to find the exact cause. I made some progress though, I'm almost understanding what's happening, so thanks for your help so far in that regard