Fork me on GitHub

@mattly, this might be a co-incidence but I find things went smoother when the src-cljc were listed before the src-clj and src-cljs. Is this lein or boot?

Pablo Fernandez10:07:59

Is using a multimethod a good way to dispatch from URLs/silk to views like the one expressed here: (@domkm is that how you’d do it?)


I'm using that style of dispatch with bidi.


Bonus is that you can provide custom hierarchy to defmulti


And dispatch generic views for the whole sections

Pablo Fernandez10:07:53

@ul: custom hierarchy? what do you mean?


@pupeno: Sure, that's a reasonable way if you want to extend dispatch from multiple namespaces.

Pablo Fernandez10:07:47

@domkm: does it fix the problem of reloading code not being used


@pupeno: Could you clarify what problem you are referring to?


@pupeno: My personal preference is to locate that sub-component routing logic within the parent component and pass route params down the render tree. For example, the top level component would have a cond that checks the route params and chooses the correct sub-view based on that.


(def routing-table ["/" {"section1/" {"page1" :handler1 ...} ...}])
(def route-hierarchy (-> (make-hierarchy) (derive :handler1 :section1) ...))
(defmulti View (fn [db] (:route db)) :hierarchy #'route-hierarchy)
(defmethod View :default ...) ; any page without specific view
(defmethod View :section1 ...) ; any page of section1 w/o specific view
(defmethod View :handler1 ...) ; view is specific for handler1


@pupeno: I don't really understand the reasoning for that use of var in Luminus. If that namespace is reloaded then the current function would be used regardless of whether pages refers to vars or symbols. Also, cljs vars do not exist at runtime, right?


@pupeno I do front-end reloading with Leaven ( I just restart the system whenever a file is saved. It works very well as long as all state is kept within components.

Pablo Fernandez11:07:32

@domkm: @yogthos said that the problem was when the functions are distributed across namespaces, I didn’t try it myself.

Pablo Fernandez11:07:40

I use figwheel to reload my code


@pupeno: Understood when they are used in a different namespace than where they are defined but in that example they are defined and used in the same namespace.

Pablo Fernandez11:07:03

Yes, the template is just designed to a have a good style to follow for bigger applications. I was wondering if the multi-method way, by its very nature, doesn’t require the vars.


@pupeno: I think multimethods would suffer from some of the same issues but I'm not sure. Locating dispatch logic within components totally solves the reloading issue so I would suggest that. It's also what @jrychter was suggesting recently.


@mfikes: Oooh, Cognicast - I’ll have to check that out.


@cfleming: Maybe it will convince you to try some stuff on your iOS device. :)


@mfikes: I’m already convinced, all I need is time simple_smile

Pablo Fernandez11:07:54

@domkm: I added a Silk example to Pushy’s README: I’m not 100% sure it’s correct and idiomatic though.


@pupeno: Great, thanks! It looks fine to me but I'm not familiar with Pushy. :)


is there dynamic scope in cljs?


@akiel: dynamic vars work as they do in Clojure


@mfikes: than I'm doing something wrong - I'll check again


@akiel Are you using binding?


@mfikes: sorry my fault - dynamic scope is working - its another problem


@akiel: No problem. (Yeah, that bit of code looked correct.)


Does anyone know how to control the order of javascript dependencies as provided via deps.cljs in another cljs project? it doesn’t seem to matter what order one lists them in (:require…), nor what order they are listed in deps.cljs. eg/


>>> :requires (Optional) A vector explicitly identifying dependencies (:provides values from other foreign libs); used to form a topological sort honoring dependencies.


@maria I haven’t. I can’t say I understand what I would put in the :file option there; it seems to want a URL. I’m trying to use JS files that are in another cljs project (say, my-codemirror-wrapper)


@maria my understanding is that I can use deps.cljs to specify files & associated synthetic namespaces that should be made available to whatever project requires my lib; then, as with cljsjs, to consume those provided namespaces one wouldn’t use :foreign-libs at all. but maybe I am missing something


@mhuebert: sorry, I think I misunderstood your questions. I thought you would be able to change the options in deps.cljs.


@mhuebert: you can only use deps.cljs if you’re planning to make a jar with your js and externs files — is that what you’re intending to do?


@maria oh… I am in control of both repo’s (I have a CodeMirror wrapper that I am using in multiple projects) so yes I can modify the deps.cljs.


@mhuebert: if not you need to pass the things to the compiler directly as :foreign-libs


@mhuebert: also there’s a codemirror package in cljsjs but you probably know that simple_smile


@maria I was confused & thought you meant compiler options of the project I am importing to


@martinklepsch: yes simple_smile. I’m working on some custom modes & things which I want to package together


@mhuebert: then I would try to modify your deps.cljs and add the :requires options as described here:


@maria perfect, thank you!


I have a weird compiler issue: Complex project, compiles release builds in 3min I make some minor changes, and it takes over 20min Likely that the javascript being processed by google closure is ‘hard’ for it? [optimizations :none is fine] Is there any way I can diagnose this further?


have you switched all the debug flags on and inspected their output, timothypratley ?


@dnolen might be able to help with where to look


I did use :verbose, but haven’t tried :cache-analysis, will give it a shot, thanks simple_smile


:cache-analysis doesn’t help, I think the reason is that is the JS being compiled by closure that is taking all the time, not the clojurescript part.


(cache-analysis only affected the clojurescript compilation part)


'Applying optimizations :advanced’ is where all the time is spent


maybe I should be searching for the answer in google closure world, any suggestions on how to do that?


thanks, will do simple_smile


@timothypratley: did you try :recompile-dependents false first


Closure isn't used under :none


Ah, I didn’t try it, because the problem isn’t in the clojurescript compile time part… but will try it now


yeah, same deal. I don’t think any of the clojurescript flags will affect the JS or time closure takes to ‘optimize’ it. note that even :whitespace optimization is taking exhibiting the behavior… so in some sense it is not a clojurescript problem at all, except I suspect the JS that is being produced is somehow hard for closure to process.


:recompile-dependents affects all settings


And there's a known poly time bug in it


gotcha. I think my problem is different, setting the flag didn’t affect it.


@timothypratley: the other thing how much RAM are you giving the JVM?


Long question: I often find the need to inspect certain values that are used within let or go. Usually I’ll stick a log in there, or I’ll set a symbol to its value and then get that symbol at the repl. Often this means I have to switch from namespace to namespace, which isn’t necessarily that easy with overly long namespaces. Basically, I’m looking for a way to easily grab a value to play around with in the repl, without having to switch namespaces. I’d considered (set! js/ and then would work in any namespace. But it occurred to me that the same would work just as well interning a symbol in cljs.core. I’m not sure how to do that except through the repl itself, however, as I believe interning isn’t available in Clojurescript. Is there a way to expand the symbols in cljs.core from another file? Or is there a better solution to debugging let values via the repl without having to switch namespaces?


wildermuthn: I like to put values into an atom with swap! / conj, but with eg. the chrome inspector you can also set a breakpoint inside the let body and look at the locals


hmmm I don’t have any settings currently, will try throwing some in


yeah, I find an atom works great for that


I add a swap! call into the function body, and if the value is immutable I can then access the atom from the repl safely


@noisesmith: sorry, misread what you said. Is the atom namespaced?


all atoms are namespaced


Right, so I’m looking for a way to do this without having to switch namespaces


but you can use require or even use to conveniently access another namespace


(require '[some.other.unweildy.ns :as uw])


you can do that in the repl


then access @uw/some-atom


Ultimately, I’d like to intern these in cljs.core so I could use them throughout my app.


oh, not for debugging but for accessing the values? I think that indicates a design problem


I could just set them in the repl everytime I loaded up, but wondering if there’s a programmatic way to do it, or if there’s just a better solution overall.


putting things into cljs.core is a bad idea


No, for debugging. Often I’ll have a value that then gets processed further within the let. I’ll usually want that value to work out what’s happening in further functions down the line.


is it really so onerous to use require while debugging?


or even in-ns


I need shorter namespaces. But I’ll often switch back and forth between namespaces, and without repl tab complete (vim + figwheel), it does get onerous.


:jvm-opts ["-Xms2g" "-Xmx2g”] <— same behavior


Basically, I want non-namespaced symbols for debugging.


wildermuthn: you could put an atom into js/window


then it's easy to get at it from anywhere right?


using swap! / reset! / deref as apropriate


@noisesmith: Yeah, I added a snippet above with a macro that does that. But then I still have to reference those macros in each namespace where I’ using them 😉


java -Xmx2g -Xms2g -jar ~/Downloads/compiler-latest/compiler.jar --js target/cljsbuild-compiler-0/**.js <— also takes a really long time.


wildermuthn: that's not using atoms, I think you'll find with atoms it's simpler and doesn't require macros


wildermuthn: my preference is to have (atom []), then use swap! to conj things on. Then I can peek to see the latest, but also access the history of values


@timothypratley: huh, in past there were some JS parsing edge cases that would cause problems. specifically large data literals, but that had since gotten fixed.


@timothypratley: the only other thing I can think of is make sure you’re getting the right version of Closure Compiler.


hmm, the version I downloaded from the web was the latest version, just downloaded now shrug. I’m working with a colleague to get a smaller repro, we now know the code conditions that cause it.


I did add those macros to cljs.core, but if there’s anyway to inject those macros I’d love to be pointed in the right direction.


But I have to say, doing this in Javascript would have required going into V8 and writing C++? Pretty cool.


@dnolen: we found the minimum repro

[:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a [:a]]]]]]]]]]]]]]]]]]]]]]
take 50 seconds in “Applying optimizations” (google closure) this is as you suspected, a nested data literal (every step takes about 2x time)


this is with a brand new repo created with lein new mies nested


while 22 is quite a bit of nesting, we actually encounter this in a page that we render with nested divs etc, and it all looks pretty reasonable (I mean we aren’t being frivolous with our divs)


ClojureScript / React Native on front page of HN now simple_smile


(just to clarify, we don’t have 22 divs nested, the ‘width’ of the nested items affects compilation time as well)


@wildermuthn What you want is analogous to having a "dev profile" for dependencies, except for interned vars, right?


So you have certain tools available no matter what ns you're in


Or maybe the reverse? I want to include those interned vars.


Without clogging up your actual requires


Let me know if you get a good solution!

timothypratley17:07:18 <— seems relevant, in theory the build has this but I’m trying to figure out a way to confirm.


@wildermuthn: I wonder if there'd be anything relevant in


Hacking something to load a namespace while injecting your "dev namespace" into its requires may be more trouble than it's worth though


@chancerussell: yeah. I’d love to dig in deeper to how namespaces work, but in compilation and at runtime. For now I just threw in two macros in .m2/etc


@dnolen: <— my colleague found the closure simplest repro, and opened a ticket there


note it is slightly different from nested literals in that in involves functions


@timothypratley: good catch, awesome that you tracked it down!