Fork me on GitHub

I trying to get the values of a protocol definition from another namespace and there is no success. Can someone help me with this? (edited) How does one accomplish this? (edited) I am using clojurescript by the way.


@iha2 define "get the values of the protocol definition"? there are only functions defined by the protocol you can call? no values to get?


(defrecord Nav [text link nav]) (def articles (map-indexed #(Nav. (->> % second :title) ’(::article {:id (->> % first)}) nil) (:articles @app-state)))


(js/console.log (:text (first nav-tree)))


I made a mistake when I said protocol


I meant record


When I import the value with the record, if I want to get the text property (as defined above), I get null.


however if I print the record I see it.


it isn't clear what (js/console.log (:text (first nav-tree))) this is?


(:text the-record) should be fine


the map-indexed looks suspicious to me. it expects a (fn [idx val] ...)


I don't think you can use second or first and instead should be using %1 and %2


the nav-tree is a list, that’s why I’m using first


I can just post both files to avoid confusion


the entire (def articles ..) looks very strange to me. so I would check if that outputs what you expect first


I doubt it does. seems very likely to me it just creates (Nav. nil nil nil)


I’ll look into it

Mikko Harju07:10:27

Our cljs-project has 702 CLJS files and some 16 dependencies as well. It seems that when a source file changes, and figwheel-main recompiles it, it is sending everything to the CLJS compiler to do its thing. The performance with lein-figwheel is better, almost 3 times faster, which means 10 seconds in comparison to 30 seconds of compilation after a file has been saved. How one should react to this? Should modularization help? The project we are doing will be getting bigger in size, and I started transitioning from lein-cljsbuild+lein-figwheel to figwheel main to modernize the build tools at the same time. My workflow has always been to evaluate stuff from the editor directly, and not relying on the figwheel’s reload functionality that much. However the rest of the team are used to just let figwheel compile the stuff, and see the changes in the browser.


I don't have any advice regarding figwheel but others have told me that shadow-cljs is substantially faster in bigger projects

Mikko Harju09:10:07

Thanks for pointing this out. Actually I was going to give shadow-cljs a spin too at this point for some benchmarking. I really like it – thanks a lot for making it! I’ve used it in many smaller proof-of-concept and other short lived projects and it has worked very well.


For what it's worth, at Nextjournal we disabled the auto reload from fogwheel, instead just using a repl workflow where you reevaluate the forms you change. Can't get much faster than that.

Mikko Harju12:10:15

@U07FP7QJ0 yes. That’s what I’ve been saying. Maybe that’s what I’ll start enforcing 😄 Thanks!


@U07FP7QJ0 So just so I understand the approach correctly. I would change a reagent component function, send the function to the repl. But I guess I would also need some mechanism to render the UI again to run the updated code?


maybe I’m missing the obvious. Maybe creating my own shortcut in the REPL for running my render-fn

Mikko Harju05:10:58

@U21QNFC5C, exactly. Just provide a shorthand for doing the re-mount after a change in a view function.


Tried it yesterday evening in Cursive, worked beautifully after a couple of tweaks. Really great!

👍 4

there probably is an easy fix for figwheel though. it shouldn't take that long unless you are changing a file that literally every other file depends on somehow

Ben Hammond07:10:41

can I get a field value out of a deftype object? I have a value which is an instance of

(deftype Reconciler [controllers effect-handlers co-effects state queue scheduled? batched-updates chunked-updates meta watch-fns]
I was hoping I could use a keyword lookup, like (:state reconciler); but it keeps coming back as nil Is there some javascriptt accessor that I have to use?


it should be (.-state reconciler)

Ben Hammond07:10:59

oh square bracket work: reconciler["state"]

Ben Hammond08:10:30

js dot notation too reconciler.state

Ben Hammond08:10:57

agree that .- is more idiomatic


@ben.hammond be careful with accessing internal things like that, it might not be safe in :advanced compilation

Ben Hammond08:10:27

I expect this particular thing to remain constant, it get sets once at :init time and then I'm only reading from it

Ben Hammond08:10:52

thanks for the warning though

Ben Hammond08:10:01

@thheller or do you mean that it might not be readable in :advanced?

Ben Hammond08:10:23

given a short name


(.-state reconciler) should work

👍 4

access via the string likely will not

Ben Hammond08:10:07

ah good to know, thanks


Does someone have experience with I managed to get it going, but now I want to upgrade to cljsjs/ag-grid-enterprise. It seems that ag-grid-react is putting some wrapper on ag-grid-community, but this wrapper is missing in ag-grid-enterprise. There is also an cljsjs/ag-grid which uses ag-enterprise, but it is outdated as it uses the version 17 and not the current 21.


I use it at work


Cljsjs/ag-grid is deprecated


You can depends on enterprise, just make sure to require it after the community edition and it will upgrade the community edition


@thheller I wonder if you know the reason why shadow can be faster than figwheel main? Looking at figwheel through JVM profiler it looks like 99% of the time goes into cljs compiler


@roman01la I suspect figwheel-main is just doing more work than it should. one common reason is the over eager :recompile-dependents where shadow-cljs uses a "different" strategy leading to less recompiled files overall


:recompile-dependents is a CLJS compiler options so not figwheel specific. entirely possible that CLJS itself is doing too much and not figwheel