Fork me on GitHub
#clojurescript
<
2017-01-11
>
stuartrexking05:01:49

Does anyone run ClojureScript tests using cider?

Pablo Fernandez07:01:32

@sandbags I just saw your message. free-form.core/form is for forms that just use reagent while free-form.re-frame/form is for when you are using re-frame. The difference is that core/form just calls a function and re-frame/form issues a re-frame event.

Pablo Fernandez07:01:45

@sandbags also, be aware that in version 0.5.0, you specify :bootstrap-3 as an argument to form, not as an option inside the form, as I implemented an extension system (react-toolbox extension coming soon… hopefully). There’s also a debug extension now that can be useful to help figure out what’s going on when the form misbehaves.

Pablo Fernandez07:01:19

@sandbags I’m glad you find the library useful and let me know if there’s anything else you’d it to do.

malcolmsparks08:01:20

I'm running all the clojurescript tests in all 4 engines using ./script/test - trouble is one of the Nashorn tests fails (pprint-table-tests) - where's the best place to discuss this? is there a dev channel?

ejelome08:01:23

maybe in the #testing channel

anmonteiro11:01:02

@malcolmsparks: #cljs-dev is the place to go

anmonteiro11:01:24

Also, the pprint failures on Nashorn are probably not your fault and have been there for a while

dnolen12:01:06

@malcolmsparks we don’t care that much about Nashorn failures, it’s the most immature JS engine and it has problems with regard to the JS language specification and standardized quirks

malcolmsparks12:01:50

thanks @dnolen - helps to know that

malcolmsparks12:01:39

fwiw, it's the only failing test and it's to do with table formatting so probably not critical - I haven't been able to figure out what the test is failing on but I might have a go at fixing it

malcolmsparks12:01:12

good to see how many tests there actually are in clojurescript, very impressive

danielstockton14:01:34

Are .querySelector and querySelectorAll the right things to use in cljs to query the dom? I'm having real trouble trying to iterate over them reliably.

danielstockton14:01:34

the (println tr) is never called, the first println prints a NodeList

danielstockton14:01:52

I have this to make NodeList seqable: (extend-type js/NodeList ISeqable (-seq [array] (array-seq array 0)))

dnolen14:01:59

@danielstockton if you want NodeList to be seqable that’s what you have to do

dnolen14:01:38

ClojureScript isn’t going to extend those kinds of types

danielstockton14:01:02

I know, the problem is that it still doesn't work the way I expect. Should items inside the seq be normal dom nodes that I can again query?

danielstockton14:01:36

Can't work out why (println (seq (q-all table "tbody tr"))) returns nil.....there are definitely tbody tr elements in the table

dnolen14:01:20

it’s easy to verify your assumption with a debugger

dnolen14:01:23

or more printlns

danielstockton14:01:41

Thought it would be, but it's not proving that way.

danielstockton14:01:49

I'm missing something weird

dnolen14:01:03

@danielstockton you can get a NodeList from table that contains children?

dnolen14:01:34

you need to avoid calling into your own stuff if you’re checking your assumptions

danielstockton14:01:44

How would you verify it has children? Most of the methods on NodeList return an Iterator

dnolen14:01:01

@danielstockton pretty sure NodeList is array-like

dnolen14:01:25

it should have a length property

dnolen14:01:42

otherwise array-seq wouldn’t work

scaturr14:01:09

According to google closure docs, native Promise should be polyfilled. I have some code using native promises, and the polyfill does not seem to be having an effect? Should I just use goog.Promise?

danielstockton14:01:24

Hmm, length is 0

dnolen14:01:45

ClojureScript has nothing to do with there being zero children 🙂

dnolen14:01:57

@scaturr where do you see this documentation?

danielstockton14:01:00

Yeah, I just can't see why it would be empty 😞

scaturr14:01:18

The initial NOTE: section at the top

dnolen14:01:52

@danielstockton console.log table, you should be able to mouse over that in Chrome and the element inspector will highlight it

dnolen14:01:15

if you see children in the element inspector then you have a race - the table is populated later

danielstockton14:01:15

(println (.-length (q-all table "tbody")))
    (println (.-length (q-all table "tbody tr")))
Here, the first is length 1 but the second is 0, perhaps querySelectorAll doesn't support this kind of selector

danielstockton14:01:35

Ah, i'll try that

dnolen14:01:31

@scaturr that doc is misleading

dnolen14:01:09

you probably need to configure Google Closure to polyfill that - not sure how that’s done

scaturr14:01:51

probably not necessary though right? It looks like goog.Promise has an equivalent interface

dnolen14:01:17

@scaturr I don’t know what you are trying to do

scaturr14:01:36

i just have some promises i am resolving when an image is loaded

dnolen14:01:36

if you just want a promise-like thing then no not necessary

scaturr14:01:27

and for library code, it probably isn’t possible to configure google closure reliably right?

dnolen14:01:38

@scaturr I don’t know what you mean

scaturr14:01:04

it sounds like some configuration is needed for google closure to polyfill things?

dnolen14:01:12

if you mean you want to use poly-filled Promise and it work for downstream library users

dnolen14:01:17

no probably won’t work

scaturr14:01:24

yes, that is what I meant 🙂

scaturr14:01:42

I’ll give goog.Promise a whirl

scaturr14:01:58

thank you :thumbsup:

danielstockton14:01:00

It's a race condition, no idea why though. If i initialize the table with a 1000ms delay in componentDidMount then it works fine.

scaturr14:01:27

If anyone happens to see the above thread, goog.Promise works as a drop in replacement for native promises. :thumbsup:

dnolen15:01:56

@danielstockton yeah mixing React and serious DOM querying is unlikely to lead to fun results

dnolen15:01:09

I suspected as much

danielstockton15:01:05

I'll probably rewrite it in a more om/react friendly way. I'm trying to translate some jQuery that a designer came up with and don't think they're really compatible.

Aron15:01:47

this is really really hard to read for me https://clojuredocs.org/clojure.core/require

Aron15:01:25

maybe i should write on another chanel, again 🙂

sandbags15:01:30

Is there a good way of replacing a function defined in a library with one of your own (instrumenting it to debug it)? I've tried re-defining it via the Figwheel REPL and this works but is fiddly since the REPL isn't a good code editing environment. I tried create a new namespace and then re-opening the library namespace to redefine the function and this seemed to work for a while, then I started getting "Uncaught Error: Namespace "ajax.core" already declared." errors from the console.

dnolen15:01:05

@sandbags I don’t know about your other problems - but you can always set! to replace some definition

sandbags15:01:58

@dnolen ah, thank you, i will try that instead

sandbags15:01:17

ah, except they are using a macro to define their func

sandbags15:01:21

i wonder how hard it's going to be

dnolen15:01:27

I don’t see how that can matter

sandbags15:01:58

well you may see better than me

sandbags15:01:14

but they are not using (fn ..) or (defn ..) but some kind of home-brew currying macro

dnolen15:01:31

what I mean is, it can’t matter

dnolen15:01:40

it just expands to def eventually

sandbags16:01:25

maybe i am just tired from banging my head against this for several hours, or perhaps i am just not at the same level of understanding as you

sandbags16:01:55

but i'm not sure how I set! the return from a macro since that will be some form of def

sandbags16:01:02

not the thing being def'd

sandbags16:01:05

ah but perhaps you meant to create your new function under a new name using the macro and then set one to the other?

dnolen16:01:22

@sandbags the macro must expand to def

dnolen16:01:30

there’s nothing else to think about here

dnolen16:01:39

(def some-var-name …)

dnolen16:01:46

(set! some-var-name …)

sandbags16:01:39

@dnolen i don't see how that helps me. where do i get the "..." from exactly? Are you suggesting I pick through the macro expansion?

dnolen16:01:01

@sandbags I think you’re inventing stuff I’m not talking about

sandbags16:01:19

@dnolen i think i just don't understand what you are saying

dnolen16:01:22

imagine some macro called (foo …)

sandbags16:01:28

let's not imagine

dnolen16:01:37

(foo bar …) -> (def bar …)

dnolen16:01:53

in order to redefine bar

sandbags16:01:55

this is my instrumented version of their code

dnolen16:01:01

just call (set! bar …)

sandbags16:01:31

right, but my question was how I obtain the thing I want to pass as ... to the set! call which wasn't obvious to me.

dnolen16:01:45

how is it not json-read?

sandbags16:01:53

unless i just define my new function as e.g. json-read-2 and then set one to the other

dnolen16:01:56

(let [old some.ns/json-read] (set! some.ns/json-read (fn [] …)))

dnolen16:01:26

then in the closure if you need the old one use it

sandbags16:01:30

yes but i don't have that (fn [] ..) ... okay let's stop there, thanks for trying to help

dnolen16:01:35

or you can write some helper fns for this

sandbags16:01:55

i'm not sufficiently alert or clever to see what you see so clearly

dnolen16:01:56

@sandbags but you’re instrumenting it, are you not going to write (fn [] …) yourself ???

sandbags16:01:36

@dnolen at the risk of going around the circle again ... no, i am instrumenting their function

dnolen16:01:05

@sandbags which means you’re going to write the instrumentation part no?

dnolen16:01:20

that’s what (fn [] …) the wrapper instrumentation stuff you intend to write

sandbags16:01:22

@dnolen i posted the instrumented code in the snippet above

dnolen16:01:48

the snippet doesn’t make any sense to me yet. I’m just explaining how you should instrument in general.

dnolen16:01:11

but if you want to use your version instead (and replace theirs)

dnolen16:01:24

(set! their.ns/json-read my.ns/json-read)

dnolen16:01:18

this is also what with-redefs is for if you want it to be temporary

dnolen16:01:27

though it won’t work async

sandbags16:01:56

that's okay, it's no problem to just patch this right in

sandbags16:01:03

the set! version should be just fine

rauh16:01:49

@sandbags At the risk of further confusion: I sometimes just copy and paste the entire namespace into my src folder (at the appropriate place for the ns), this means all the imports, namespace aliases etc are all available. And then just edit the code as you like. Once you're done, just remove the entire file.

sandbags16:01:10

@rauh actually that probably would have been easier 🙂

sandbags16:01:12

however it looks like defining my own instrumented function and using set! has worked, so thanks again @dnolen apologies if i was being a bit dense but clearly not seeing on the same level as you

dnolen16:01:38

no problem

sandbags16:01:59

now, if this would just make a difference to my real problem (swamp meet alligator)

timsgardner21:01:05

Repling into clojurescript via figwheel-sidecar.repl-api/cljs-repl, I'm getting swamped by huge error messages when large data fails in cljs.spec.test/instrument'd functions. Anyone know a way to intercept/limit the size of error messages in this context?

cfleming23:01:58

Any tips for debugging “Uncaught TypeError: Cannot read property 'getHostNode' of null” in a reagent app?

cfleming23:01:51

Reading the React issues, it seems like this is due to React getting into a funky state when previous errors are swallowed using e.g. promises, but I don’t have anything like that, unless reagent uses them internally.

mikethompson23:01:49

I haven't seen that error before. Perhaps ask in #reagent channel to plug into broader experience. @cfleming

cfleming23:01:00

@mikethompson Thanks, I’ve asked over there.