Fork me on GitHub
#clojurescript
<
2019-02-01
>
lilactown01:02:21

do I not know how lexical scope works?

lilactown01:02:58

I had some code that was essentially:

(def some-coll ["foo" "bar" "baz"])

(doseq [item some-coll]
  (-> (async-thing)
      (.then (fn [] (println item)))))
and it would just print "baz" three times

dnolen01:02:11

we capture locals around anon fns, you should make reproducer

dnolen01:02:35

that should work - the only thing odd here is the loop is at the top-level

dnolen01:02:40

maybe that's a missed case

Sturm03:02:08

can anyone suggest a lint tool like eastwood that's suitable for ClojureScript? (my reading is that eastwood is Clojure only)

👍 10
aspra12:02:52

Hi all, any suggestions for libraries and especially forms that do not require Javascript on the client side?

thheller13:02:54

odd question to ask in a clojurescript channel 🙂

thheller13:02:52

you can do simple HTML forms without JS and without any libs (if you are talking about server rendered HTML)

thheller13:02:04

if you mean CLJS forms then all of them generate JS

aspra13:02:33

@thheller I was thinking the same while typing 🙂 I know there are some libs that also support server side rendering for example. I am looking for something along these lines and more specifically for forms.

aspra13:02:51

Maybe should ask same questions on the Clojure channel 🙂

jimberlage13:02:09

You probably already know about it, but I’d use hiccup

jimberlage13:02:37

I’m not aware of anything that generates interactive forms for you like rails’ form_helper and friends

jimberlage13:02:09

But those kind of convention-driven forms would be relatively easy to make a library for

aspra14:02:02

right, thanks @jimberlage. + for hiccup. Used in the passed https://github.com/teamwall/formidable but not sure if it is maintained

cjohansen14:02:28

after a longer debugging session I seem to have discovered that in cljs.core.async, the go macro "eats" meta data, could that be right? Anyone else seen this?

cjohansen14:02:01

cljs.user=> (meta ^:some-meta [])
{:some-meta true}
cljs.user=> (a/take! (a/go (meta ^:some-meta [])) (fn [v] (println v)))
nil

dnolen15:02:29

it's possible

Alex Miller (Clojure team)15:02:07

have you tried using with-meta instead?

borkdude15:02:44

I cannot have an expression as a fallback value in goog-define, only literals?

thheller15:02:43

yes, they are compile time constants

cjohansen16:02:46

@alexmiller I haven't. Ended up moving the literals outside the go macro in the tests I was working on. But this seems like a bug, guess I should report it somewhere proper

dnolen18:02:21

@borkdude and not just literals

dnolen18:02:43

just a few primitive JS types allowed

dnolen18:02:49

boolean, string, number is what I recall

mfikes19:02:34

Yep, that's in the docstring for goog-define

borkdude19:02:13

yeah, when I read ‘value’ I didn’t know if this was a literal string/number/boolean or could also be something that evaluated to a string, I mean literal in that sense

mfikes19:02:36

Upstream still has defaultValue (string|number|boolean)

borkdude19:02:37

what I wanted was something like (goog-define foo (look-into-an-environment-variable ...)), but it’s all clear now, thanks 😉

mfikes19:02:18

It might actually be possible to do something like that with the underlying Closure support. For now the macro will balk at macroexpansiontime.

ccann20:02:46

do I have to do anything special to call an async javascript function defined in a library in my cljs namespace?

ccann20:02:58

I keep getting a TypeError “is not a function”

jimberlage20:02:46

Try setting the :language-in compiler option

thheller20:02:45

@ccann no special settings required no. should work fine assuming you have the correct reference. did you check whatever you are calling is what you expected? (eg. by logging it before you call it? (js/console.log the-thing) (the-thing))

ccann21:02:34

hmm thanks, it’s undefined, so something else must be going wrong. I’m trying to pull in a library my coworker wrote via ["foo" :refer [baz]]

ccann21:02:53

and baz is undefined

thheller21:02:50

try ["foo" :as foo] and (js/console.log "foo" foo)

thheller21:02:28

js exports are often a weird mix of es6 exports and commonjs exports

ccann21:02:43

I had the same thought and tried that and it’s just an empty object

thheller21:02:10

any errors in the console while loading?

ccann21:02:17

looks pretty happy

ccann21:02:02

I tried a third party library shortid and that works

ccann21:02:18

so there must be something about the exports or the configuration for our lib

ccann21:02:17

I want to reference the file main.js under the project foo

ccann21:02:38

would that be foo/main :as foo?

ccann21:02:07

hmm doesn’t like that

thheller21:02:43

not sure what you mean by "project foo"

ccann21:02:12

I corrected the path and now it’s finding the file i’m trying to import but failing to compile throwing an “errors in files” on a file i’m not trying to import that’s in the same directory as the one I am. I’ll delve into this, thanks for all the assistance

thheller21:02:46

only "standard" JS is supported. if you use JSX or any other non-standard JS feature you might need to preprocess with babel

ccann21:02:55

thank i’ll reach out to the author

ccann17:02:14

I got this working, by the way. Added a babel step 🙂 as you said

lilactown23:02:35

was there some utility added in the last CLJS release for converting a JS error to a map?