Fork me on GitHub
#clojurescript
<
2017-06-19
>
thedavidmeister01:06:45

what should i put in an extern file for objects returned by another method in the extern file?

thedavidmeister01:06:49

like, a factory method

minikomi04:06:04

Is there a pattern for non-protocol-defined methods on deftypes ? For cases where only one kind of deftype has the method..

noisesmith04:06:15

every method on a deftype must come from a protocol or interface

minikomi04:06:31

OK that’s fine with me

thheller04:06:39

@minikomi in CLJS you can actually just do (deftype Thing [x] Object (foo [this] ...)) (.foo (Thing. :x))

thheller04:06:55

ie, define functions on Object

noisesmith04:06:04

oh, I had no idea

minikomi04:06:14

ahh yeah i thought I saw something along those lines thanks!

thheller04:06:17

CLJS only, CLJ can’t do that

minikomi05:06:27

experimenting with doing some 2d stuff in the browser using cljs.. currently abusing deftype as an alternative to dropping down to js objects to avoid GC with a lot of updates each frame

urbanslug08:06:56

Hey, so if I successfully compile my cljs app with target being nodejs meaning it can then be used as a node lib what’s the way to go about making it a node lib that can be installed with yarn/npm

urbanslug08:06:05

Meaning it would need a package.json

urbanslug08:06:15

How do people go about this?

urbanslug08:06:31

Basically I want my cljs lib to be used in a node app.

urbanslug10:06:49

@thheller Yeah, I saw your lib and tried it out.

urbanslug10:06:01

Plus you told me about it the last time.

urbanslug10:06:05

I think I’ll try it

thheller10:06:09

in fact if you yarn add --dev shadow-cljs .. it has been built with it 😉

urbanslug10:06:32

Problem was that I didn’t have a package.json

thheller10:06:46

yeah you need that if you want to publish to npm

thheller10:06:06

the CLJS code gets compiled into the cli folder there

pesterhazy12:06:13

Was playing with clojurescript datastructures for use as queues (fifo or lifo), so I made this table to visualize the differences: https://gist.github.com/pesterhazy/4dac98a570b9534e56cace78b945bc62

acron14:06:14

Does anyone have experience with async tests in cljs.test? I am struggling to get this simple test working:

(deftest async-test
  (async done
         (let [result (atom nil)
               foo (chan)]
           (go
             (>! foo 123)
             (reset! result (<! foo)))
           (time/sleep 1000)
           (is (= 123 @result)))
         (done)))

dnolen14:06:20

@acron that’s not going to work

dnolen14:06:34

you’re calling done before the test is done

acron14:06:36

@dnolen time/sleep is

(defn sleep [msec]
  (let [deadline (+ msec (.getTime (js/Date.)))]
    (while (> deadline (.getTime (js/Date.))))))
If I used an async timeout would that work ?

dnolen14:06:54

fix your test

dnolen15:06:00

put done in the right place

dnolen15:06:05

move the tests into the right place

dnolen15:06:11

i.e. inside the go block

acron15:06:08

@dnolen thanks! it appears the code hangs on putting the value in the foo channel

dnolen15:06:43

there are no takers

acron15:06:54

Sure, I'll shuffle this round a bit

dnolen15:06:08

you probably want two go blocks

dnolen15:06:20

one to write, one to read

dnolen15:06:36

and get rid of time/sleep

dnolen15:06:44

that’s just a bug - you cannot sleep in single threaded environment

acron15:06:24

perfect, thanks @dnolen

acron15:06:26

(deftest async-test
  (let [result (atom nil)
        foo (chan)]
    (async done
           (go
             (>! foo 123))
           (go
             (reset! result (<! foo))
             (is (= 123 @result)) 
             (done)))))

dnolen15:06:38

looks right now

acron15:06:40

just a toy test, now I can build on this

hlolli17:06:22

I'd like to implement eval-sexp in AceEditor, for cljs project. Does someone know if this has already been implemented somewhere, just trying to save time.

hlolli17:06:31

Basically just select beginning and end parenthesis of s-exp that the cursor is placed at, at any given moment.

zilti18:06:35

Are there some common errors that cause the browser to go "SyntaxError: expected expression, got ')' [learn more] void();:1:5"? There's no hand-written js code in my project, it's all cljs.

dnolen19:06:47

not that I’m aware

dnolen19:06:07

there’s not enough information here to know what might be going wrong

zilti19:06:17

Ok. I guess I'll keep trying stuff. Weirdly enough, I get that message, but it doesn't break anything. Maybe it's in a js dependency...

dnolen19:06:48

browser should tell you which file the error came from

dnolen19:06:53

JS dev console

zilti19:06:28

@dnolen: sadly "void();:1:5" is the "file position" it tells me ^^

dnolen19:06:49

try a different browser

dnolen19:06:36

Safari, Chrome, Firefox all can give slightly different, and slightly more useful errors depending on the case

pesterhazy19:06:01

also try clearing your lein cache (if you're using lein) and try a different browser (to avoid weird browser caching issues)

mikepence19:06:30

looking for recommendations for a library to use to do Capybara-style tests that drive the browser.

uk128819:06:46

Hi. I would love to use materialize with reagent-ui in building my clojurescript SPA. Can I just import materialize as a library into the main html file while using reagent-ui or will I have to use material-ui?

mikepence20:06:53

looks like you could do either