Fork me on GitHub
#clojurescript
<
2019-09-17
>
johanatan02:09:18

hi, i have a weird issue where the chrome network tab shows that a 303 was returned along with a 'location' response header to an XhrIo ajax call. yet the XhrIo object itself has a status of 200 and the 'location' response header is missing from .getResponseHeaderson the same XhrIo response object.

johanatan02:09:36

any ideas if this is a bug in google.net.XhrIo or something else?

johanatan02:09:30

[to complicate matters there are two layers of abstraction between myself and XhrIo: re-frame-http-fx & cljs-ajax.

johanatan02:09:58

[but i installed an interceptor in the latter and should have had access to the unmolested XhrIo]

p-himik05:09:23

I think it's followed automatically. Maybe you don't see the request that returns 200 due to some filter in the Network tab (or it very well may be a bug in the Network tab - I've seen plenty). More details: https://stackoverflow.com/questions/3820663/is-it-possible-for-xhr-head-requests-to-not-follow-redirects-301-302

johanatan20:09:40

ah, that could be it. in this case, i don't want the AJAX call to follow it automatically. we need to redirect the user's browser to that location, not merely a bkg request.

johanatan20:09:54

is there a way to tell reframe, ajax or goog.xhrio that they should not follow this one?

p-himik14:09:55

It's all there, just read the answers at that link: "There isn't, this isn't exposed behavior you can stop".

andy.fingerhut06:09:37

Does anyone know of a public ClojureScript project that uses cljsbuild and Leiningen to run tests defined using cljs.test/deftest, that I can look at as a working example?

roklenarcic09:09:38

:refer-macros is old stuff, right? No longer needed?

thheller09:09:02

@roklenarcic depends on how the macro itself is created. if it has the necessary setup then :refer-macros is not required yes

roklenarcic09:09:26

hm... not sure what that means, but I'm trying to use go-loop async

thheller10:09:52

@roklenarcic (:require [cljs.core.async :refer (go-loop)]) if you have the latest core.async

magnars12:09:19

Any ideas why my src/data_readers.cljc file is also read as a normal clojurescript file, and thus fails with No such namespace: time for my {time/inst ...} reader literal? Trying to quote the symbol doesn't help, because then the actual data-readers code complains about the quoted symbol.

plexus12:09:35

@magnars are you using Figwheel? can you move it to resources?

magnars10:09:39

@plexus this did infact work, fyi 🙂

magnars12:09:48

I am using Figwheel. I'll try that.

magnars12:09:30

@plexus Thank you, that helped. That was a much better ending to my work day than I had anticipated. 🙂

plexus12:09:39

Figwheel compiles everything under src I think, regardless if it's required or not

magnars12:09:45

ahh, but now it seems ClojureScript compiler doesn't see it.

magnars12:09:09

either way, I'm a bit further, so I can experiment some more with the class path shenanigans.

plexus12:09:27

what you can also try (hax0r warning), is prefixing the symbols with ^:cljs.analyzer/no-resolve

magnars12:09:40

ooh, hax0r!

thheller12:09:48

use :main in the build config, that may prevent it trying to compile everything?

thheller12:09:34

also don't use data_readers.cljc in the first place. just configure your reader properly at runtime.

magnars12:09:02

I am trying to get the data reader online in time to parse .cljs-files.

magnars12:09:15

I do have a :main.

thheller12:09:26

don't use data literals in code, unless you want to suffer through all sorts of weird issues with caching and so on

magnars12:09:13

that's a fair point.

thheller12:09:08

#time/inst "2019" is also not much shorter than (time/inst "2019") 😉

magnars12:09:53

that's true, but trying to read data literals in code is due to a few other issues 😛 we have regressions tests, and since the clojurescript compiler only watches for .cljs and .cljc-files for reloading, we put the regressions test data in a .cljc-file - instead of an .edn-file. And so we are here.

magnars13:09:31

but your advice seems sound - we'll have to move the regression test data out to .edn again, and find some other way of keeping it up to date.

thheller13:09:27

another option is just running an external file watcher that runs touch src/test/my/tests.cljs on change

thheller13:09:49

chokidar-cli on npm is an option

magnars13:09:16

thanks for the tips, I'll take a look at that 🙂

dazld13:09:55

hey, I’m trying to update an old project from cljs .439 to .520 and getting a compilation error message with no context. is there somewhere that compilation logs can be seen..?

thheller13:09:29

you can set :verbose true in the build options

dazld13:09:50

Failed to compile build :ios from ["src" "env/dev"] in 6.549 seconds.
----  Could not Compile  src/foo/bar.cljs  ----

  failed compiling file:src/foo/bar.cljs

----  Compiler Error : Please see src/foo/bar.cljs  ----

dazld13:09:52

looks like this

dazld13:09:02

i’ll try, thanks!

dazld13:09:58

same error, sadly

dazld13:09:01

no extra info

dazld13:09:13

the last thing it tries to compile before hitting that file is core async

dazld13:09:53

oh, wonder if it’s reagent?

thheller13:09:33

what are you using to build? seems weird that the error is missing? or are you just omitting the stacktrace?

dazld13:09:30

it’s an old re-natal

dazld13:09:37

oh, lein-cljsbuild

awb9917:09:44

Can someone recommend me a nice UI table component? I need a table that keeps column and row headers and can scroll the data if rows and columns are bigger than the viewport.

nenadalm18:09:05

I am using material-ui (react library): https://material-ui.com/components/tables/#sorting-amp-selecting for tables and bunch of other stuff

awb9918:09:44

I have tested material ui

awb9918:09:01

But I seem not to be able to get it to do what I want 😞

awb9918:09:21

`(defn my-table "material ui table headers: vector [field-selector name formatter linker] rows: the seq to be displayed as a table" [headers rows] ; [mui/paper {:square true ; :style {:background-color mui/secondary ; ;; :text-align :center ; :padding "0em 0em 0em 0em" ; :width "100%"; "400px" ; :marginTop "10px" ; :overflowX "none" ; :overflowY "none" ; } ; } [mui/grid {:container true} [mui/grid {:item true :xs 12} [:div {:style {:overflow-x "auto" :overflow-y "auto" }} ; Fixes overflow outside screen [mui/table ;; Headers [mui/table-head (into [mui/table-row] (for [field headers] [mui/table-cell (get field 1)]))] ;; Body (into [mui/table-body] (for [row rows] (into [mui/table-row] (for [field headers] [mui/table-cell (get-field-data field row)]) )))]]]])`

awb9918:09:42

As soon as the number of rows extends the table on the vertical side above the screen,

awb9918:09:50

then the column scrolling is not working.

awb9918:09:11

I have experiemented iwth the overflow settings also.

dazld19:09:21

did you need sorting etc?

dazld19:09:18

if its just for display and don’t need any interaction, then you can get quite a long way with just html & css

✔️ 4
awb9919:09:32

I would prefer sorting also

awb9919:09:58

Perhaps I have to wrap the table into something..

Roman Liutikov20:09:47

react-virtualized

awb9920:09:24

@U0FR82FU1 thanks - I will try that

sova-soars-the-sora21:09:20

hi, does anyone know how i can read the data attribute of a dom element via cljs?

sova-soars-the-sora21:09:19

or how can I use getAttribute?

gerred22:09:28

.-(attribute) right?

gerred22:09:36

.-innerHTML el

gerred22:09:47

.-class el

gerred22:09:45

aget is an option too

gerred22:09:55

and for nested props

gerred22:09:59

.. is there for you

dpsutton22:09:49

anyone ever extend a protocol onto js/DOMRect and js/MouseEvent for top and left so it looks more uniform rather than (- (.-clientX e) (.-left X))? Is this pointless, or maybe has pain later on, or is this kinda what its made for?

athomasoriginal02:09:53

I like the fact that inerop code looks like interop so I might not want to reach for this. Did you have anything else in mind other than aesthetics?

dpsutton02:09:45

yeah it was to make the math seem a bit more straight forward. but there were better ways around it. but it was principally aesthetics

dpsutton22:09:46

its quite simple but really its just property access so i'm wondering if the uniformity is trumped by the added indirection

paul a22:09:33

i can't understand what's going on in this code i wrote. basically, i want to make a request and throw some error JSON if the response wasn't ok, but i'm getting all tangled up in promises. would someone be willing to take a look with me?

paul a22:09:11

or maybe throwing for a successful but non-200 response isn't the right thing to do? i'm not sure of the conventions in this domain

awb9922:09:28

I made this code. Not sure if this is good code or not. I have build a dashboard with multiple components that all get passed a symbol for which they should get data. The components manage the fetching of the data they have to get. Now in order to trigger reload on change, I made this function. I basically make a function that does not return anything visible, but does trigger the api reload. The nice thing is that my components can be normal Level2 components with easy syntax, and I avoid the more complicated syntax.