Fork me on GitHub
#clojurescript
<
2017-05-25
>
claudiu08:05:31

Hi. Playing around with colocated-css queries. In development mode and simple optimisations when i do (pr-str Component) I get a string namespace/Component but with advanced optimisations I get #object[$U "function (){React.Component.apply(this,arguments);this.state=null!= this}"].

claudiu08:05:07

Has anyone encountered this, is there another way to get namespace/Component with advanced optimisations ?

thheller08:05:48

@claudio the code that makes that works seems to get removed by :advanced. not sure if intended or bug

claudiu08:05:45

@thheller totally missed it I had :pretty-print false in options. Thank you

thheller09:05:35

that should not make a difference

errigal75110:05:43

Hi, hoping someone can just point me in the right direction here, I don't seem to be searching in the right direction: trying to use cljsjs/pdf.js with re-frame/figwheel, no problem requiring the library itself or invoking functions on it, but this particular library tries to retrieve an additional file (when using figwheel) http://localhost:3000/js/compiled/out/cljsjs/pdfjs/common/pdf.inc.worker.js, the pdf.inc.worker.js is in the cljsjs/pdf.js bundle but clearly not where pdf.js expects to find it. There is a property in PDFJS that can bet set for the workerSrc url but its not clear what it should be set to. Cheers

darwin11:05:54

@claudiu I believe this is a bug[1] in CLJS, see point #1, you seem to be printing a constructor name which does not work under :advanced https://dev.clojure.org/jira/browse/CLJS-1249

darwin11:05:37

as a workaround you could be able to invoke (.cljs$lang$ctorPrWriter obj obj writer opts) by hand, see the relevant code

frank15:05:03

is there a way to remove keys from js objects in cljs without the use of js->clj?

frank15:05:38

šŸ˜® thanks @thheller !!

frank15:05:39

the reason I'm asking is because js->clj seems to throw when passed js objects with the "v" key, but only when the code is advanced compiled

frank15:05:33

ah cool :thumbsup:

jmromrell16:05:50

I am running into a problem where (.createElement js/document "svg") returns #object[HTMLUnknownElement [object HTMLUnknownElement]] and cannot be added to the DOM using .appendChild

jmromrell16:05:40

running JS: document.createElement("svg") in the console returns a svg node, as I'd expect

mobileink16:05:52

Iā€™m having an interop problem. I have a js prototype object, with a field that take a function ref, e.g. :observer 'foo'. I want to delegate to a cljs namespace, e.g. :observer acme.widgets/foo-observer. I use clj->js to convert the prototype object. Iā€™ve tried various ways to do this (including using _ instead of -) and canā€™t get it to work, i get ā€œmethod not definedā€. but it looks like it is defined, all the namespaces are correct, and goog.required etc.

mobileink16:05:39

so i guess the short version is: how can I pass a reference to a cljs fn in a prototype object that is converted using clj->js?

jmromrell16:05:56

re: my problem above, I actually managed to add the svg node to the DOM despite the HTMLUnknownElement type, when I run the command directly in figwheel.

jmromrell16:05:11

But an identical function is not working in my source code

jmromrell16:05:26

I'm guessing it has something to do with my reagent class creation:

jmromrell16:05:46

(r/create-class {:component-did-mount (partial jaeger/postload state) :component-did-update (partial jaeger/postload state) :reagent-render (fn [] (side-by-side state jaeger/render))})

jmromrell16:05:14

where state is a reagent atom and postload is the function that should create/add the svg node

jmromrell16:05:52

I can confirm via printing that postload is getting called, and appendChild is running

jmromrell16:05:17

Is there some trigger I am missing besides component-did-mount and component-did-update? Something that runs afterwards that is removing my changes?

iandavis17:05:24

@dnolen Are there any gotchas I should worry about removing the first three cases from js->clj? https://dev.clojure.org/jira/browse/CLJS-2050?focusedCommentId=45719#comment-45719. It seems like it would be fine if we are just using it for json parsing, but wanted to double check.

dnolen17:05:28

@iandavis Iā€™ve already stated in the ticket you cannot change js->clj

iandavis17:05:49

sorry, I meant your suggestion of an internal copy

dnolen17:05:59

yeah šŸ™‚

iandavis17:05:02

i understand we cannot change it in core

dnolen17:05:02

that would work

dnolen17:05:17

sorry @iandavis just noticed it was you

iandavis17:05:24

great. what are those first three checks there anyway?

iandavis17:05:33

iā€™m usually pretty quiet here.

dnolen17:05:39

itā€™s just vestigial stuff

dnolen17:05:51

to be honest I always thought js->clj was not a good thing to have in core

dnolen17:05:02

and I always recommend against it

dnolen17:05:09

and now we have to live with it

iandavis17:05:12

just trying to imagine in what scenarios i would have clojure objects inside my js objects?

dnolen17:05:41

@iandavis many people are not so careful, sometimes people put stuff in to roundtrip through some JS api etc.

iandavis17:05:17

that sounds like it would cause trouble.

dnolen17:05:21

anyways I think adding more cases to js->clj was a terrible idea and should have pushed back on that more

dnolen17:05:33

but people really wanted it

iandavis17:05:43

if I have any compalint about the clojures, itā€™s that sometimes people can be not so careful

dnolen17:05:14

one option would be to move it to a deprecated ns and put a more disciplined one in place

iandavis17:05:28

for now, our workaround is fine.

dnolen17:05:43

or just make a new js conversion thing and warn about js->clj being deprecated

dnolen17:05:02

^ probably the best path to getting people off it

iandavis17:05:09

and despite the harrowing route I had to go down to track down the root cause, i know a lot more about the guts of cljs now which is nice

iandavis17:05:30

yeah, yā€™all did something like that with js* awhile ago right?

dnolen17:05:55

we didnā€™t deprecate we just removed all obvious usage from cljs.core

dnolen17:05:23

anybody using it is asking for trouble eventually

dnolen17:05:20

@iandavis I will say your problem is a sign of a wider problem - we might want cljs$lang$type property to be a sentinel instead of a boolean

dnolen17:05:04

and then protect protocol bitmask checks with a CLJS type test - but need to benchmark to see how much of a hit that would be

djtango18:05:31

Hi all - question, is cljs.reader/read-string safe for receiving arbitrary client data?

darwin18:05:45

unless you re-configure it to do something dangerous, of course šŸ™‚

noisesmith18:05:31

oh - it looks like #= doesnā€™t exist for cljs.reader

djtango18:05:41

@darwin great thanks for the info!

noisesmith21:05:19

is there a simple way to take some data in my clojurescript app in dev and store it on disk? Iā€™m using figwheel if that makes it easier

noisesmith21:05:51

on disk as in another process or a unit test could grab the data and use it

noisesmith21:05:42

OK yeah I already use data URIs, so I guess I need to add a dom node to my app in the browser for the href

noisesmith21:05:58

oh wait that example calls click rightā€¦

john21:05:13

yeah, most of the examples, I think

john21:05:12

I think I've heard folks ask that same question twice recently. That gist should be helpful.

noisesmith21:05:34

thinking of using it to make a cljs ns for poirot https://github.com/noisesmith/poirot/ which is for lowering friction to creating data based unit tests using data that is already in your running app

john21:05:52

Interesting... a sort of hybrid between repl testing and build testing?

noisesmith22:05:02

@john a bridge, I find that my team is great at playing in the repl to get things working, but not so great at turning those repl experiments into tests that we can run automatically

noisesmith22:05:52

the hope with this library is to make it easier to say ā€œOK - I know how this works in the repl, better make some unit tests to document and automate my assumptionsā€

noisesmith22:05:28

because when someone else comes back months later, they donā€™t know what you did in the repl to prove this function worked!

noisesmith22:05:43

so how do they know that their change to the function makes sense? etc.

john22:05:10

That's true

john22:05:56

You dogfed that thing yet with the team?

john22:05:13

@noisesmith You can also do interesting things with fileReader. I believe there is a way to incrementally read and write to a user provided file. https://stackoverflow.com/questions/14842214/html5-filereader-how-to-only-read-the-first-n-characters-of-a-file

noisesmith22:05:21

yeah - Iā€™m looking at how to do the other side of the conversion too (load test data into a repl)

noisesmith22:05:57

@john yeah Iā€™ve been encouraging the team to use the tool, and once we get some good experience using it and any weirdness ironed out Iā€™ll publicize it a bit

noisesmith22:05:26

Iā€™ll probably make custom readers for things like atoms and js-bigint thingies that show up in a lot of our cljs data that we would want to round trip