This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-09-23
Channels
- # admin-announcements (24)
- # alda (1)
- # aws (10)
- # beginners (15)
- # boot (51)
- # cider (37)
- # clojure (198)
- # clojure-berlin (3)
- # clojure-czech (48)
- # clojure-poland (1)
- # clojure-russia (7)
- # clojure-seattle (1)
- # clojurescript (347)
- # editors (64)
- # emacs (46)
- # hoplon (13)
- # immutant (24)
- # jobs (17)
- # ldnclj (20)
- # ldnproclodo (3)
- # off-topic (8)
- # om (37)
- # onyx (19)
- # re-frame (18)
- # reagent (54)
- # remote-jobs (2)
- # testing (9)
- # yada (1)
- # yleinen (4)
So, just had to share my ClojureScript joy of the day. I’ve got ClojureScript running in both the browser and nodejs, with both running on Figwheel, and communicating via websockets. Full-stack ClojureScript? Crazy, or beautiful?? 😄
Next step is syncing my DataScript datom diffs across all connected clients.
@wildermuthn: Congrats!!! It's kind of a strange place to be heh? The client and the server using the same exact hot loaded code, its kind of disorienting.
Definitely top-ten mind-blowing experiences. The figwheel guide made it very simple to get going. It reminds me of trying VR for the first time. Conversion on the spot.
@wildermuthn: did you follow a guide to get this setup? Could you share any tips? Thanks
cljx is kinda deprecated now right? What's a good example of a project that uses ".cljc" to good effect to provide portable code?
Ah looks like garden has updated: https://github.com/noprompt/garden/blob/master/project.clj
@noprompt: What are the advantages of generating CSS with Clojure?
@cddr cats is my goto example of cljc portability https://github.com/funcool/cats
@danielgrosse: clojure
@quantisan: what are you trying to do?
@danielgrosse: in general: you treat CSS as data, so you can apply functional composition and transformations to it before you generate final CSS (using familiar clojure libraries), think of it as SASS/LESS with macros. A second big advantage is that you can share constants and other data between your app and css. Really nice when you need to generate some styles inline during your component rendering, but they have to match other CSS rules or share animation timings between javascript and CSS. Real world example: https://github.com/darwin/faceboard/tree/master/frontend/styles/faceboard
@afhammad: if that jquery lib uses jquery, then jquery is already present in your page, right? why not using it?
@quantisan: I guess my question is if foo is a native dom function or it is a jquery method, or some jquery plugin method
@quantisan: just skimmed their docs, it looks like they depend on jquery and they implemented their api as jquery plugin only
@quantisan: so, if that’s true, you have no option to not include jquery, it will be included
just checked their github code here and I can confirm their code heavily depends on jquery https://github.com/zurb/foundation/tree/master/js/foundation
@quantisan: simply make sure you included proper version of jquery into the document and call their api via (.foundation (js/$ js/document) <args>)
Hmm when using :optimizations :advanced
, I'm not expecting the output file to be including information about the source file path, yet I'm seeing many many references to the source file, encoding my local file path in the file. That's unexpected, given such files are targeting production environments. Am I crazy?
@pupeno: I think you can update https://github.com/clojure/clojurescript/wiki/Compiler-Options#target now your patch has been merged?
@bo: use :pseudo-names true, and post again https://github.com/clojure/clojurescript/wiki/Compiler-Options#pseudo-names
@cddr You already mentioned a pretty clean cljc project. The hard part is getting the tooling straight. @pri has done a wonderful job on this side, see facjure/garderner.
@bo: it is likely your fault, I guess some macro is emitting those strings, production logging maybe?
@darwin: toggling pseudo-names
definitely changed the output, but the paths are still present
+ return $mujic$chords$$;
+ }, $cljs$core$cst$0sym$0mujic_SLASH_chords$$, $cljs$core$PersistentHashMap$fromArrays$$([$cljs$core$cst$0kw$0ns$$, $cljs$core$cst$0kw$0name$$, $cljs$core$cst$0kw$0file$$, $cljs$core$cst$0kw$0end_DASH_column$$, $cljs$core$cst$0kw$0column$$, $cljs$core$cst$0kw$0line$$, $cljs$core$cst$0kw$0end_DASH_line$$, $cljs$core$cst$0kw$0arglists$$, $cljs$core$cst$0kw$0doc$$, $cljs$core$cst$0kw$0test$$], [$cljs$core$cst$0sym$0mujic$$, $cljs$core$cst$0sym$0chords$$, "/Users/bjeanes/Code/mujic/src/mujic.cljc",
The src code that I think this corresponds to is using ns-interns
which very likely is including this extensive metadata
@darwin: it doesn't seem to be asserts, but the metadata associated with the interns seems more likely. I'm guessing ns-interns
is a macro which is causing all the interns and the full associated data to to be written out and slurped up by Closure, even though I'm only using the intern names
Interesting that I can't see this metadata with :optimizations :none
though. I'd expect it have a superset of information, not a subset
When I start cljs autocompilation, I get 'clojure.lang.ExceptionInfo: failed compiling file:src/mk/fe/router.cljs`. If I change anything, compiler complains with java.io.FileNotFoundException: Could not locate core/utils__init.class or core/utils.clj on classpath.
I surely don't have core/utils.clj, but I have mk/fe/core/utils.clj, and I require it like that everywhere. Any thoughts what's going wrong here? I tried cleaning up artifacts already...
@bo: you should be able to fix it with a simple re-writing macro, where you cherry-pick only stuff you care about
darwin: yeah now that I have somewhat of an idea where the problem is, that was my thinking also
@darwin: the src code is the very bottom of https://raw.githubusercontent.com/bjeanes/mujic/master/index.org
@bo: yes, that’s the ns-interns call, it generates (into {} [bunch-of-stuff]) this won’t get optimized away by closure
I still don't know why I can't find the same junk in the non-advanced compilation, but maybe it's just not where I am looking
@darwin: the only place I can find that string in the output-in
dir is in the .cache.edn
file
@darwin: yeah actually I'm looking at the output of the same section, now that I know the source, and it seems to be using relative paths instead of absolute
e.g.
var intern_kv = cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,cljs.core.PersistentVector.fromArray([new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.symbol.call(null,"chords"),new cljs.core.Var(function(){return mujic.chords;},new cljs.core.Symbol("mujic","chords","mujic/chords",1711103068,null),cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"ns","ns",441598760),new cljs.core.Keyword(null,"name","name",1843675177),new cljs.core.Keyword(null,"file","file",-1269645878),new cljs.core.Keyword(null,"end-column","end-column",1425389514),new cljs.core.Keyword(null,"column","column",2078222095),new cljs.core.Keyword(null,"line","line",212345235),new cljs.core.Keyword(null,"end-line","end-line",1837326455), ...
new cljs.core.Symbol(null,"chords","chords",1875513344,null),"src/mujic.cljc",12,1,448,448,cljs.core.List.EMPTY,null,(cljs.core.truth_(mujic.chords)?mujic.chords.cljs$lang$test:null)]))], null)
@bo: you will have to write your own specialised version of ns-interns or use some narrower api-call to fetch only what you need
I can also be less clever there. this was just a temporary little thing to let me defer wiring up my interactive examples in the post
And it led me to a ClojureScript bug and subsequent patch due to my use of a ♯ symbol in keywords 😉
Anyone using khroma or writing Chrome extensions in ClojureScript? https://github.com/suprematic/khroma/tree/develop I’m extending it, so if anyone has notes or comments, now’s the time.
I’m also wondering about the best approach for writing tests for something like khroma, since lots of functions aren’t present unless you’re running as an extension with the right permissions. My current thinking to make a Chrome extension that presents a set of devcards with the test results.
@ricardo: I haven’t but I would like to in the future - I’m interested in your experiences using it.
@cfleming: It’s very bare-bones and barely documented. I’m adding wrappers for functions that I need, improving function docstrings, renaming for consistency, that sort of thing.
@ricardo: Sounds good. It’ll be a while before I need it, but I’m glad there’s something there - I searched a while back and couldn’t see anything.
I wonder if there is a way for macro to require dependency in case it wasn’t already required. In my homebrew macros I learned to use fully specified method names including namespaces, but still there is that pesky problem that macro user has to have the namespace required at call site when using the macro. Those requires seems to be unnecessary to unaware reader. I usually tend to remove them during code cleanups and then learn hard way that they were needed by some macro actually. How do you guys deal with this?
@wildermuthn: Congrats - it is a great place to be. I am using Clojure/ClojureScript with EDN and it just rocks.
@danielgrosse: The other win for CSS in Clojure is the symmetry between hiccup and keywords. Jumping between hiccup-style and then SCSS (or plain CSS) just jars. The number of times I have typed .myclass { :width 10 }
in CSS and then scratched my head….
@darwin give the ns and the macro ns the same name. Then require like so (:require (my.foo :refer-macros [bar]))
@asolovyov: you’ve expressed something less than Clojure 1.7 as a dep
@dnolen: thanks, will try to do, but not always macros reside in the same namespace, sometimes I want to write macro which does some work generating code using functionality from other namespaces (e.g. macros which sugar usage of a 3rd party library)
@bo: it doesn’t matter what optimization setting you use, ns-interns
will dump vars, remove it if you don’t want that
@darwin there’s no better solution to that problem and unlikely to be - the same story in Clojure really, you can’t refer to stuff no one ever loaded
Finally, my NodeJS powered library for pre-rendering ClojureScript applications is ready: https://carouselapps.com/prerenderer/
@dnolen: I thought so! But I found it just 20 mins ago - it was lacking a dep somewhere in the unrelated module. Figwheel actually showed me better error in overlay, I just didn't pay attention there
This is my first macro. If someone can take a look at it and point out shortcomings, I'd appreciate that! https://gist.github.com/mbertheau/3a90c1bc46ea660bc8ea
Hey all, I’m including some stuff as web-jars. Right now I just <script> import each of them in the html; but is there a better way of combining them?
(in this particular case it’s react and react-boostrap (using Reagent, but getting react-bootrap to work requires explicitly importing it on the window)
@joelkuiper: this is why most people don’t use Webjars much with ClojureScript, if you use CLJSJS you get dependency ordering and even more important you get externs
right, but that makes the interpop story with existing libraries (like react-bootstrap) a bit tricky
@joelkuiper: c’est la vie, this is how ClojureScript works today
fair enough
@joelkuiper: I see that CLJSJS has react-bootstrap
btw, http://cljsjs.github.io
ah, thanks! Might try that instead!
@joelkuiper: the order you should try things
good to know, I’ll try and see if I can get it to work with the CLJSJS lib thanks!
@joelkuiper I am continually surprised by how rich 2) turns out to be, so my list would be 1), 2), 2), (really sure?) 2) 3)
@dnolen: I find it about as accessible as a gold mine unfortunately - is there a good pick-axe (e.g. high-level guided tour documentation) you know of?
@colin.yates: that’s the primary issue with it, the only saving grace is that it’s well commented / readable JavaScript
fair enough - thanks.
it might be a good idea for http://cljs.info or something like it to provide the high level docs for commonly used GCL namespaces not sure what @shaunlebron thinks about that.
goog.assert
, goog.math
, goog.date
, goog.string
, goog.object
, async module loading, internationalization, dom helpers, event stuff, etc.
it would be great to document these in a more visible way for a ClojureScript audience
there are various bits in the GCL testing lib which are pretty slick (I used PRNG for CLJS test.check), the crypto stuff is useful etc.
@dnolen: CLJSJS worked perfectly, thanks
+1 - I found out to write an auto-reconnecting websocket client is three lines for example.
time I imagine, as ever, is the constraint though
@colin.yates: a wiki approach seems to work with the ClojureScript community, there just needs to be a convenient wiki to send PRs to
a github book might be the thing then...
never mind - I thought it was free for open-source books
@dnolen @darwin I'm getting on a plane but it occurs to me that it could be possible to analyze/compile a cljs ns dynamically in a macro definition. Yes yes nasty hack
I was thinking about wrapping whole file in a macro call, but I rejected it, maybe if cljs compiler had option to wrap each file in a form specified on as compiler option, but still it could bring more troubles, with ides and other tools
@darwin I think a wrapper ns for the main namespace that includes the libraries will work. Warnings will get thrown on first compile.
@bhauman: I’m not sure if I follow. how would that macro know about something which is coming later and referencing lib xxx?
I was thinking about deep-walking macro which would get fully expanded file and just add missing requires
Also if we could specify an ns as a build input to the compiler you could do conditional includes that way as well.
@bhauman: a different topic: in one of your talk I saw that you used figwheel as continuous testing environment, you had a web page with your test results and did that cool favicon trick when something failed, pretty sweet, do you plan adding something like that into figwheel or maybe thinking about another library on top of figwheel maybe part of devcards?
Over last two days I wasted some hours trying to make karma runner work this way, but it was mission impossible
I’m thinking also about clojurescript-specific tool which would be smart enough to re-run only tests affected by code changes
the idea of running tests in browser directly is neat, because if something goes wrong you have debugger at hand to peek into it
How is (for [example [1 2]] (button-cell example))
different from (map button-cell [1 2])
? I'm getting Wrong number of args (1) passed to app.widgets/button-cell
for the for variant.
will use my own deftest macro, which can do devcards' deftest or something else depending on situation, but from top-level it will have deftest shape
just for record, if someone wanted to use karma watching cljsbuild auto mode, it is not working fo me under OSX, karma does not wait for files to be fully written and corrupts its own caches: https://github.com/darwin/plastic/commit/8e7ccecbbd51b7b87d95362293732d29b4444e89
not sure whose fault it is, but I guess clojurescript compiler is not doing anything crazy when writing files
maybe it is just a bit slower in writing file contents and exposes karma’s bug that way
so I posted this in the #C06DT2YSY channel last night but might as well posted here https://github.com/swannodette/om-next-demo. Presented with little in the way of docs or how to run it, but still might be of interest to anyone who has been following Relay/Falcor or the various tidbits I’ve shared about Om
still under heavy dev, but getting pretty excited about how it allows you to determine how much reactive logic you split between server and client. this is a direct result from Falcor providing unified client/server routing model.
this means it’s easy to write a rich server which reflects back changes to the client, and the client becomes very simple and very declarative.
most of the server side stuff can be completely ignored in that repo, typical Clojure web app boilerplate
https://github.com/swannodette/om-next-demo/blob/master/todomvc/src/clj/todomvc/parser.clj
also https://github.com/swannodette/om-next-demo/blob/master/todomvc/src/cljs/todomvc/core.cljs
can see that client becomes super declarative once you colocate queries, they present data and trigger mutations (some which may run on client some which may run on the server - this is important).
this is context for my oblique tweet basically instead of sending HTML fragments around, Om apps are data deltas managed by queries
so we get the benefits of Relay for page load, but we also index every single component in the UI - so if the server says update this logical identity Om can find every rendered instance of the thing and update that too. This is Falcor-ish.
it is possible to (deftype MyThing []) and have MyThing inherit all PersistentHashMap protocols?
@dnolen: ok, thanks, was wondering, started with plain map and now would like to turn it into deftype and add some protocols
@darwin this is what records are for, unless for some reason you can’t use its defaults
@dnolen: I was feeling that record is too heavyweight for my case, I just wanted a type validation checks, will stick with plain PersistentHashMap
@dnolen: record does a lot stuff, not sure about performance of construction and map functionality, maybe it is ok, never used records much before
@mbertheau no difference AFAIK must be a lazyness issue
for example records keys lookup compiles to a switch statement on strings, this is way faster than hashing to find a value, the only thing that might be faster than this would be a small array-map with a couple of keys.
re: construction, if you use the raw ctor, no real construction overhead worth talking about
the primary down side of records everything is prebaked, and that two records of different type but same keys will fail equality.
Oh jeez now I'm going spend my time reading om next demos instead of working on my Strange Loop talk. Thanks a lot David
@dnolen: my map is dynamic, I wouldn’t specify any record params and rely on it’s dynamic nature, I assume it would boil down to same performance as PersistentHashMap
yeah records don’t support transients, but update perf on basis keys isn’t going to be slow.
@dnolen: thanks for all the info, btw. speaking about transients, would be nice to provide printing support for them
@darwin: another question to sort out in Clojure first, discuss after that, then maybe consider it for ClojureScript
rule of thumb if you think some language enhancement might be interesting it generally needs to pass muster or gather rationale from Clojure first
@dnolen: is there something like cljs.analyzer/error-message
that’s public? Wondering how figwheel creates it’s warning messages
@martinklepsch: might not be but not for any particularly reason, that’s definitely something to export into a public ns
@val_waeselynck: Ah, laziness. Thanks!
@dnolen @colin.yates tracking possible GCL docs for cljs here: https://github.com/cljsinfo/cljs-api-docs/issues/145
current version of planck, also http://clojurescript.net
these are all 3rd party things with 3rd party issues running on a bleeding edge feature - optional bootstrap
@mfikes were you aware about 0 being falsey? i was typing up an issue for planck when u ponged me
@mfikes I though that was fixed in planck, I don’t believe we understand the root cause of the issue though
My best guess is http://dev.clojure.org/jira/browse/CLJS-1423
@dnolen: Yeah… that ticket is only minimal in the sense that it doesn’t involve 3rd party things like Planck. But it currently only goes so far as to show requiring cljs.anayzer can cause it. Hrm.
@mfikes the case doesn’t explore the fact that in a bootstrapped context cljs.analyzer/*unchecked-if*
doesn’t exist
@dnolen: I'll take a look at that ticket again. My last memories if it involved trying and failing to construct metacircular arguments that would explain the behavior. :)
@dnolen: I can’t seem to create a controlled component in Om anymore. minimal bug reproduced: https://github.com/shaunlebron/om-control-bug
(dom/textarea #js {:onChange (fn[]) :value (:text data)})
should be the same as <textarea onChange={(function(){}} value={this.props.value}/>
but adding an empty onChange event in Om makes the state get out of sync for some reason
@shaunlebron: I'm not sure I understand correctly but it seems like that has always been the intended behavior
@bensu: oh thanks, that explains exactly why that’s happening
having said that, this is at odds with trying to prevent certain states in the textarea
e.g. preventing characters from being typed
@shaunlebron: I'm not sure what is desirable but that is how I remember it working since.... well forever.
I don’t have access to my old Om code base, but I had to prevent invalid date strings in an input field by cleaning the text in onChange
IIRC the way to do that was to provide :onChange
, filter the chars, and handle it yourself. I think it's covered in the om intermediate tutorial.
not sure how I did that now
@bensu, thanks, that’s the behavior that I expect actually
@bensu: updated the example, I’m pretty sure this should work, but it doesn’t: https://github.com/shaunlebron/om-control-bug/blob/33f3e79c920959e0f3c8271f5cdf7e6dc8a9b78c/src/om_control_bug/core.cljs#L16
the app still allows me to type “x”
@bensu: oops, bad code. this still isn’t working: https://github.com/shaunlebron/om-control-bug/blob/ebe4bc96c745cd5317e7cdf4e8271e1261e372ca/src/om_control_bug/core.cljs#L16-L21
@shaunlebron: that looks correct. I'll try it out
@bensu: typing axxxaxxxaxxxa
will only refresh the component when you type a
, bug must be related to change detection
@shaunlebron: I got to the same conclusion, after typing
@bensu: thanks for looking at it
the problem is not on change detection since the callback gets called on every keystroke
@bensu: I think Om only schedules updates when app-state changes. the app-state value doesn’t change when you type an “x” so the component is never updated
@shaunlebron: bingo.
I don’t see why value is being kept in local state
I think that’s the source of the problem though
IIRC React already has some magic behavior around inputs and for implementation reasons om can't leverage directly. then it has to provide it's own input layer which is dependent on the React version/implementaiton. I think this is where the bug comes from.
Hello, adding https://github.com/onyx-platform/onyx seem to make my lein figwheel
command fail, did anyone experienced something similar ?
I mean, I see why it’s happening, the local state is being changed, which triggers a component update, and of course it uses the local state value
@shaunlebron: right
completely ignoring the prop
I gotta grab dinner
Exception in thread "main" java.lang.ExceptionInInitializerError, compiling:(cljs/repl.cljc:1:1)
at clojure.lang.Compiler.load(Compiler.java:7239)
.....
Caused by: java.io.FileNotFoundException: Could not locate clojure/tools/reader/impl/ExceptionInfo__init.class or clojure/tools/reader/impl/ExceptionInfo.clj on classpath.
at clojure.lang.RT.load(RT.java:449)
it looks like a cljc
problem. you are using clojurescript that requires cljc
files but a clojure version that can't
hmm I am using 1.7.0, lein repl
gives :
`
nREPL server started on port 53988 on host 127.0.0.1 -
REPL-y 0.3.7, nREPL 0.2.10
Clojure 1.7.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27
`the output it quite big, but at the beginning I have :
`
Possibly confusing dependencies found:
[lein-ancient "0.6.7"] -> [org.clojure/tools.reader "0.9.1"]
overrides
[lein-figwheel "0.4.0"] -> [figwheel-sidecar "0.4.0"] -> [clojurescript-build "0.1.9"] -> [org.clojure/clojurescript "1.7.48"] -> [org.clojure/tools.reader "0.10.0-alpha3"]
and
[lein-figwheel "0.4.0"] -> [figwheel-sidecar "0.4.0"] -> [figwheel "0.4.0"] -> [org.clojure/clojurescript "1.7.122" :exclusions [org.apache.ant/ant]] -> [org.clojure/tools.reader "0.10.0-alpha3"]
and
[lein-figwheel "0.4.0"] -> [figwheel "0.4.0"] -> [org.clojure/clojurescript "1.7.122" :exclusions [org.apache.ant/ant]] -> [org.clojure/tools.reader "0.10.0-alpha3"]
and
[lein-figwheel "0.4.0"] -> [figwheel-sidecar "0.4.0"] -> [org.clojure/clojurescript "1.7.122" :exclusions [org.apache.ant/ant]] -> [org.clojure/tools.reader "0.10.0-alpha3"]
Consider using these exclusions:
[lein-figwheel "0.4.0" :exclusions [org.clojure/tools.reader]]
[lein-figwheel "0.4.0" :exclusions [org.clojure/tools.reader]]
[lein-figwheel "0.4.0" :exclusions [org.clojure/tools.reader]]
[lein-figwheel "0.4.0" :exclusions [org.clojure/tools.reader]]
@shaunlebron: pretty sure you have to use to component local state to make controlled components works, you can’t do it via app state.
so, it might be this: clojurescript requires [org.clojure/tools.reader "0.10.0-alpha1"]
to find cljc
files and for some reason your deps (`lein-ancient`) are bringing in an older version
it might be totally unrelated but it includes [tools.namespace 0.2.11]
can you try with it?
yeah... checking that and tools.analyzer
was my last idea. I would try binary search on the dependencies now.
well I have reduced the dependencies before posting quite a bit (now I have clojure, clojurescript, aleph, timbre, component, onyx, figwheel as a plugin)
Anyone here using lein doo
?
I’m able to run it fine from my computer, and I can run it on CircleCI, but sometimes on Circle it’s blowing the memory usage up over 4GB and failing the build