This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-16
Channels
- # aws-lambda (1)
- # bangalore-clj (2)
- # beginners (121)
- # boot (23)
- # cljs-dev (165)
- # cljsrn (8)
- # clojars (2)
- # clojure (164)
- # clojure-berlin (6)
- # clojure-chicago (3)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-russia (4)
- # clojure-serbia (32)
- # clojure-sg (1)
- # clojure-spec (8)
- # clojure-uk (55)
- # clojurescript (94)
- # cursive (21)
- # datomic (30)
- # events (1)
- # hoplon (6)
- # jobs (1)
- # keechma (1)
- # liberator (2)
- # luminus (8)
- # off-topic (48)
- # om (12)
- # onyx (24)
- # parinfer (15)
- # pedestal (8)
- # re-frame (4)
- # sql (18)
- # test-check (31)
- # unrepl (70)
- # untangled (21)
@linicks i’ve never used this but this might help https://github.com/bhauman/lein-figwheel/wiki/HTML-watcher-including-browser-reloading
naomarik: i am a happy user of this plugin and it does indeed automatically reload html and css assets
What’s the cleanest way to determine if the Clojurescript has been compied for dev environment? I want to add a enable something (re-frisk) only when in dev mode. How should I go about it?
@udit condition based on goog.DEBUG
(def DEBUG? ^boolean goog.DEBUG)
Great! Thanks @mikethompson
@udit I'm just trying to remind myself if you have to explicitly set goog.DEBUG
or if it is set automatically. The docs not helping:
https://github.com/clojure/clojurescript/wiki/Compiler-Options#closure-defines
I'm sure that I remember that goog.DEBUG
is automatically set to false when you use :optimization :advanced
.
But I'm looking at our projects and seeing that we set it to false explicitly in our prod builds. So I'm now puzzled.
There’s this discussion on google groups which sheds some light onto this, apparently the default value in all cases is true
https://groups.google.com/forum/#!msg/clojurescript/7wAO_GzsITM/JicBuCjiqPAJ
@udit that's me discussing it. You'd think I'd remember :-)
@udit, maybe (verify and) update the wiki page?
I know I've been stumped on goog.DEBUG a few times, and superficial googling didn't help
@mikethompson in (def DEBUG? ^boolean goog.DEBUG)
, is the type hint necessary or a performance optimization?
Necessary if you want to trigger Dead Code Elimination (from the Google Closure compiler, in advanced builds)
(if DEBUG? something-which-you-want-DCE-from-advanced-builds )
ah got it
@udit I would recommend to use a macro which emits cljs code based on compiler options, this is IMO more predictable than depending on closure compiler/library features, something like this: https://github.com/binaryage/cljs-oops/blob/dcf6ef5f55ed858016fdd7554adc631dda11e614/src/lib/oops/config.clj#L21-L23
@darwin can macro approach be applied to cases when I want more fine-grained settings? E.g. feature flags. So that I can have several advanced build profiles producing applications with different set of features.
@metametadata yes, you can put your own options into compiler config and it will be available
@darwin that's awesome, thank you
@metametadata in :external-config
you should put your config under your own namespaced key to prevent conflicts with libraries and other foreign code
e.g. here I read cljs-oops config from compiler options: https://github.com/binaryage/cljs-oops/blob/dcf6ef5f55ed858016fdd7554adc631dda11e614/src/lib/oops/config.clj#L28-L30
Is there a convenient HTTP (or, so to speak, XMLHTTPRequest) library for ClojureScript that doesn't make the impression of being abandoned?
zilti: https://github.com/JulianBirch/cljs-ajax is probably the most popular one
I already got the recommendation on the IRC channel and am looking into it, but thanks a lot! 🙂
How about the "native" Google Closure option? https://google.github.io/closure-library/api/goog.net.XhrIo.html
@zilti I have news for you: a great library comes bundled with clojurescript: https://developers.google.com/closure/library/docs/xhrio#send-utility-function-example
A team at my company is choosing between ClojureScript (probably with Reagent and re-frame) and Elm for their frontend. Anyone here who has tried both and know some pros/cons?
ooh! yes, i know and love both. i’ve done Elm at medium production scale, Clojure only as an enthusiast
i think the TLDR is that Elm is very ceremonious. our team benefits from the very easy interrogation of Elm code, but also spend a lot of time dealing with the rigor required for things that seem trivial, but are hard to explain to the compiler
Yeah. I tried to do my current project in Elm and abandoned it for ClojureScript.
my throughput implementing Clojure features is much higher than in Elm, but i can refactor Elm like a moron when i’m very tired, and it’s not much slower, but it’s not remotely dangerous. grain of salt, though--i wish i had more production Clojure experience.
But that was because I was trying a kind of abstraction that ended up being tricky for Elm's Union Types. For a bog-standard SPA, Elm is still something I'm interested in.
i guess maybe then it matters what kind of project @curlyfry’s team is working on! what is it, if you can say?
I agree.
@bbqbaron @captainlexington Thanks for your input. My team actually already uses ClojureScript 🙂 The team that's choosing between cljs and Elm are building a relatively big web application but I wouldn't say there is anything especially out of the ordinary when it comes to interaction. A lot of forms and tables!
thanks for the answer. if you’re already using cljs--out of curiosity--what motivates considering Elm? i’m a fairly flexible polyglot, but teams seem to benefit from uniformity, so why not use what you have? (not challenging your question, sorry; genuinely wondering)
@curlyfry NextJournal transitioned from React -> Elm -> ClojureScript and talked about it here https://www.youtube.com/watch?v=Q6Q5D6mI-34&t=1s
@curlyfry IMO, Elm is fine technology, I think the biggest value add for ClojureScript is if you’re already using Clojure
@bbqbaron I actually agree with you, I think both teams would benefit from using the same language and learning from each other 🙂 The teams do work on different products though and it's up to each team to choose their stack.
I wish we had the /that/ much stack latitude at my job!
How do you guys find the js interop in Elm? I haven't tried it myself, but I've heard some people say it's kind of cumbersome
@curlyfry that said, the NextJournal story definitely opened my eyes about the value of ClojureScript even if you’re not using Clojure
and the video more less back up my claim that people who think JVM stuff is more complicated than Node.js stuff are kidding themselves
It's certainly cumbersome compared to ClojureScript. I never even tried. Supposedly it forces you into a very nice interface though.
it is as with everything else, ceremonious 🙂. at a high level, i think it depends on whether you use ports as you’re supposed to, or whether you resort to embedded native side effects as an escape hatch. the former is officially recommended, the latter is often the real world response.
I guess that's the Elm Way, though - cumbersome, but makes you do it nice
@curlyfry Elm philosophy is a bit different here they’re OK with re-inventing a bunch of stuff - ClojureScript is not OK with that
I've definitely enjoyed the js interop in cljs. Being able to use existing react components (if using a react wrapper) without much fuzz is also pretty great. You get a pretty big ecosystem almost for free.
I like both Elm and Cljs, but what frustrates me about Elm are the breaking changes the the mixed/contradicting messages from its evangelists.
Elm has an understandable bigger challenge - it’s a language that’s still evolving - we just have too keep pace w/ Clojure
yeah, but the messaging is what I have issues with. Its proponents are out there evangelizing Elm giving the impression it is stable, and when a breaking change is introduced, they are like Meh, it is not 1.0 yet.
anybody making heavy use of datascript in their apps?
For the following externs file:
var google = {};
google.script = {};
google.script.run = {};
google.script.run.doSomething = function() {};
Should (js/google.script.run.doSomething)
work? It seems like run
is being munged.@zane If you try it the cljs-oops
way, does it work?
@captainlexington unrelated, cljs-oops will work for sure in this case
If you an access it using ["keys"]
, then the externs would be the place to look
(cont) assuming cljs-oops usage (gcall "google.script.run.doSomething")
, which will compile to goog.global["google"]["script"]["run"]["doSomething"]
which will then be turned into this.google.script.run.doSomething
after advanced optimization pass, because string names are simply not subject of name mangling and goog.global gets optimized away.
Wasn't loading the externs file properly. Once I fixed that everything worked. Thanks, @dnolen, @cap10morgan.
FWIW, In my built environment I log the entire Compiler config map including the externs. Which could possibly avoid such bugs. Maybe this is something lein cljs build plugin could do or even cljs compiler itself.
I tend to use lein-pprint when hunting for project.clj / config map bugs: https://github.com/technomancy/leiningen/tree/master/lein-pprint
when extremely paranoid, I print current cljs compiler options via a macro, expanded at the point where my failing code lives
So, if something pretty-prints as:
#object[Array One Fish,Two Fish,4,Red Fish,Blue Fish,3]
how would I go about converting it to native data structures? js->clj
doesn't appear to change it.I'm guessing it's not a normal JavaScript array because it doesn't print with a leading #js
.
probably a strangely constructed array, you may need to extend js->clj
via the provided protocols
or maybe use Array.from
? https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/from?v=example