Fork me on GitHub
#clojurescript
<
2016-05-17
>
sbmitchell00:05:21

yea I've come across that myself multiple times

sbmitchell00:05:50

@dimiter: I found an aget-in useful as well

dimiter00:05:07

Thanks. Thats useful.

sbmitchell00:05:49

Has anyone here tried to analyze the render calls of a component tree in reagent/om

sbmitchell00:05:05

Id like to be able to create a visualization of how the component tree is re-rendering after a change for debugging purposes

sbmitchell00:05:22

kind of asking where I could start I suppose šŸ˜›

dimiter00:05:24

Well, I use react tools in chrome.

fasiha00:05:38

@pataprogramming @mvaline: writing cljs without knowing much about underlying JS seems scaryā€”using JS libs in that condition seems really risky? I guess it depends on the libā€”react seems pretty completely wrapped with re-frame/reagent, so reading its docs might be sufficient (e.g., I've never written a JS react app, but made re-frame apps). I did use d3.js extensively in JS before cljs, so I should probably just break down and learn how to use d3 from cljs.

sbmitchell00:05:42

does that show the render cycle and life cycles?

dimiter00:05:07

Not sure, but in any case, you shouldnā€™t be too worried about performance when re-rendering from the root.

sbmitchell00:05:14

you dont really need to use d3 from cljs aside from the different syntax right now @fasiha

sbmitchell00:05:25

In my reagent apps I completely differ to d3

sbmitchell00:05:43

I just have "container" components wrapping coordination

sbmitchell00:05:58

and everything else ends up being in the component-did-update lifecycle

dimiter00:05:59

React does a pretty great job of only modifying the parts of the DOM that need changing.

sbmitchell00:05:31

I dont see a difference from using d3 in js and cljs is what I'm trying to say I guess

fasiha00:05:15

Good to know @sbmitchell! That's great to hear it's not a big baroque production. I'm rendering map-oriented geoJSON data to SVG "manually" (i.e., no d3/SVG libs), and it works fine now, but eventually I'll want to use d3 for clipping and performance.

sbmitchell00:05:50

yea I clipped d3 in some of our graphic components like a gauge, sparkline, chart, pie-chart

sbmitchell00:05:53

its just straight svg

sbmitchell00:05:23

but for something like a force directed graph..there is no way Im figuring that out in svg over a day

sbmitchell00:05:57

thanks @dimiter interesting

sbmitchell00:05:09

I guess Im a little confused as to what I am wrapping

sbmitchell00:05:29

I mean this looks like you need to wrap specific components to get the stats per component

sbmitchell00:05:53

what id prefer is a monkeypatch to turn on during dev mode or something that looks at the render queue or something

sbmitchell00:05:05

for everything~

sbmitchell00:05:19

@dimiter: not sure how I never knew about react dev tools...seems to be quite useful šŸ˜›

pataprogramming01:05:15

Thanks for the discussion on d3/cljs...it's useful. I know I'll be limited in how far I can take this without actually figuring out the JS layer, but I'm trying to skunkworks it as far as possible before the "real" JS devs get involved.

mvaline01:05:49

I follow a similar practice of container components, it works very well

mikethompson06:05:45

@pataprogramming: anyone considering using Reagent and D3 should read the following, taking particular note of the links at the bottom of the page (to @zachcp's D3 specific explanations and examples): https://github.com/Day8/re-frame/wiki/Using-Stateful-JS-Components

annarcana07:05:45

err. mistype, sorry.

dsouth10:05:42

Sorry if thatā€™s obvious, bit of noob still

plexus10:05:17

add a #js before {:preload ,,, }

plexus10:05:53

Clojurescript maps and vectors are different from Javascript objects and arrays. You can either use the #js reader macro, or the clj->js function. The difference is that clj->js will work recursively, whereas #js will only convert the outer expression

dsouth10:05:45

nope šŸ˜ž

dsouth10:05:48

same error still

plexus10:05:41

what's the error?

dsouth10:05:58

Basically, a function call in the framework isnā€™t getting defined, so I thought maybe Iā€™ve done something wrong with populating the map

dsouth10:05:31

it fails on

callback.call(context, this);
because context is undefined

plexus10:05:47

you also need to add a dot to (js/Phaser.Game. ,,,)

plexus10:05:58

that final dot is the equivalent of calling new ...

dsouth10:05:11

yeah, missed that one, thanks šŸ˜‰

dsouth10:05:37

that did the trick. THANKS!

plexus10:05:44

pleasure šŸ™‚

dsouth10:05:57

I got a new error \o/

dsouth10:05:01

progress šŸ˜„

dsouth10:05:20

yeah, that map is now my problem šŸ˜•

dsouth10:05:27

OK, change the map to a (js-obj ā€¦) and that fixed that

dsouth10:05:19

Oh gawd, probably just best to use

& rest
on Clojure functions called from JS? šŸ˜•

plexus10:05:02

having arity problems?

dsouth10:05:57

hmm, stuck again šŸ˜•

dsouth10:05:16

not sure how to fix that arity issue

dsouth10:05:22

thanks again for you help, gotta run

dsouth10:05:39

oh Iā€™m an idiot šŸ˜‰

dsouth10:05:34

I defined it to call Clojureā€™s update šŸ˜•

ashercoren13:05:33

Does anyone have any experience with working with the servant or butler libraries for web-workers? I'm having trouble with making sure my code isn't called from the worker thread (or at least I think that's the problem)

ashercoren13:05:47

@risto: Just saw your post from last week: Is there any way to have "core.async" fetch things in paralell but still maintain the given order?. How about this?

Dustin Getz14:05:25

How can I implement toString on goog.Uri? This is hard because this is an infinite recursion:

(extend-type goog.Uri
 Object
 (toString [this] (str "#<URI " (-> goog.Uri .-prototype .toString (.call this)) ">ā€))

thheller14:05:48

@dustingetz: pretty sure Uri already implements toString?

thheller15:05:04

you are even calling it šŸ˜›

Dustin Getz15:05:12

It prints as #Object since bumping deps

Dustin Getz15:05:23

but calling the prototype directly works

Dustin Getz15:05:28

i canā€™t imagine what i did wrongt

thheller15:05:43

it prints where? pr-str?

thheller15:05:54

that is not toString

thheller15:05:11

IPrintWithWriter with -pr-write protocol

Dustin Getz15:05:26

did this behavior change at some point?

thheller15:05:42

sort of yes. clj changed the way unknown objects are printed, cljs did as well

thheller15:05:13

so if they don't implement the IPrintWithWriter protocol, they will print as #object ...

thheller15:05:25

in an effort to keep things readable

Dustin Getz15:05:29

Yeah I think this happens on JVM also, on clojure 1.6 pr-str gives me a <Uri ā€¦> but in 1.8 it gives me an <Object>

Dustin Getz15:05:39

i dont udnerstand why it used to be known and now it isnā€™t?

Dustin Getz15:05:05

(I now understand the solution is -pr-write, thanks)

thheller15:05:17

#<Uri ...> is not readable since it is not valid edn

Dustin Getz15:05:47

ah, pr-str is only writing edn-readable strings

Dustin Getz15:05:55

and it used to write out any old string

thheller15:05:01

it attempts to yes

thheller15:05:23

it used to fallback to toString

Dustin Getz15:05:51

thanks for your help, all is clear now, the infinite recursion makes sense thanks

anton17:05:20

Hi, guys. Somebody might be interested here in my sample spa on clojurescript https://github.com/arevkov/clojure-web-app. Since I have been programming on clojure for last 3 months or so any recommendations on stack of libraries, idiomatic code structure or even code review are highly welcome.

lewix18:05:20

@arevkov: do you use reframe?

anton19:05:41

@lewix: nope, I used only reagent. thanks for the hint, will take a look at that lib.

pedroiago23:05:28

can I get a value from a var in clojurescript?

pedroiago23:05:04

I've tried var-get, but it doesn't seems to be implemented