This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-09
Channels
- # beginners (38)
- # boot (160)
- # cider (143)
- # cljs-dev (62)
- # cljsjs (2)
- # cljsrn (3)
- # clojure (278)
- # clojure-austin (8)
- # clojure-brasil (5)
- # clojure-greece (2)
- # clojure-italy (11)
- # clojure-russia (188)
- # clojure-sg (2)
- # clojure-spec (118)
- # clojure-uk (103)
- # clojurescript (87)
- # core-async (8)
- # cryogen (2)
- # cursive (12)
- # datomic (119)
- # emacs (13)
- # hoplon (4)
- # immutant (12)
- # off-topic (12)
- # om (54)
- # om-next (5)
- # onyx (1)
- # pedestal (2)
- # portland-or (2)
- # re-frame (58)
- # reagent (18)
- # ring-swagger (18)
- # rum (4)
- # spacemacs (4)
- # specter (3)
- # untangled (65)
- # yada (25)
I’m trying to use http://clojure.browser.net to make an XHR request. What I have works fine in dev, but when I use advanced compilation and deploy to prod, it doesn’t work. In the network panel, I can see the request completing correctly with the correct response, but it seems like none of the events are getting triggered.
I’ve enabled all the XHR breakpoints in Chrome, and the only one that is hit is readystatechange
This works fine with :simple
optimizations, but it doesn’t use any non-CLJS or non-Goog code.
I didn't even realise that keywords could be used in place of the enums. That seems like a dangerous feature as it will break under advanced compilation?
shameless plug: We're building a open source mobile browser, messenger, and gateway to a Ethereum blockchain based on decentralised technologies and seeking contributors https://status.im/ http://wiki.status.im/
re-natal + re-frame + cljs + golang
Does anyone have experience with React table components? I'm looking at https://github.com/bvaughn/react-virtualized and https://github.com/reactabular/reactabular in particular. Ideally it should take a vector of maps and handle displaying autonomously for the most part.
@sbmitchell, hey I saw that you used react-virtualized with clojurscript
I'm trying to get it to work but seeing stacktraces related to ReactDOM
Did you do anything special to get it to work with the cljsjs package?
this is my issue: https://github.com/cljsjs/packages/issues/697#issuecomment-271283803
I've found sort-by
to be very slow when sort-fn is expensive
For example, if I sort by fmt-value
, it takes an order of magnitude longer than
(->> items
(map (juxt (comp fmt-value f) identity))
(sort-by first)
(mapv second))
Has anyone noticed that?
(in the example, fmt-value
would be slightly costly, e.g. keyword
or str
)
@pesterhazy That's expected, since your fmt-value
function will be called O(n log n)
times during the sort and only exactly N
times in the other case
interesting
I assume garray/sort also calls the compare-fn O(n log n)
times?
hmm, so is my fast-sort-fn
actually the best I can do?
that's reasonably fast even if compare-fn is slow
a generalized sort-fn that only calls compare-fn n times
is what I'm looking for I guess
The first
fn still gets called nlogn times, but the values will be precomputed, which is a good idea in case you do some formatting (which can slow)
yeah, first is fast I guess
Lots of ways to potentially get some more performance out of it if you just use (.sort (to-array ...) (fn [a b] ...))
and do the compare manually
right but that would still call compare-fn >n times, correct?
Yes, no way around that, but the stable sort will wrap it again and copy the array again.
thanks for your help!
some useful pointers
@pesterhazy If you end up writing an optimized fn, let me know and gist it. I could use it probably
So sketch: Create array manually, add the "cached" value to be compared as arr[0] and payload to arr[1], then return the arr[1] elements in the end (and seq it)
basically like my version above except using js arrays in place of vectors
@pesterhazy About 4x faster: https://gist.github.com/rauhs/913330d7f75841b013b3cf6115693687
@rauh, amazing!
@dnolen could you please point me to some docs explaining the usage of aget
and also when you shouldn’t use aget
?
google is failing me
yeah, but my colleagues don’t believe me
and I’ve told them “but David Nolen says…"
apparently that isn’t enough 😜
@bostonaholic there’s a stackoverflow thread somewhere, maybe look there specifcally 😄
@bostonaholic: aget usage is arrays only just like Clojure. No other information is necessary
so how would one retrieve nested map data on js/window
?
as I’m new to cljs, just to be clear, you’re saying to use (.-propname el)
instead of (aget el “propname”)
unless el
is a javascript array?
@joshjones yes or use (goog.object/get el “propname")
now I really want to open a PR in my app to replace all incorrect usages of aget
I usually just make a util function for js objects
(defn get-in [obj keys]
(reduce goog.object/get obj keys))
just stumbled across this https://lambdaisland.com/episodes/clojurescript-interop
(I haven’t watched the video yet so I’m unsure of the correctness)
but the section at the bottom on aset/aget is helpful
Right goog.object
is got dynamic property access. Use property syntax for anything the compiler is guaranteed to either see the definition of, or an extern has been provided for
what does dynamic property access mean in js? isn't all object property look up the same? (forgive my ignorance)
i understand on the jvm avoiding reflection is very important, but i don't know of a js parallel
I don’t mean dynamic property access for javascript, I mean dynamic property access for ClojureScript
@bostonaholic check out oget
as a smart alternative to aget
: https://github.com/binaryage/cljs-oops
Uncaught Error: No print-fn fn set for evaluation environment <-- how do I fix this? caused gy using pprint from cljs
@qqq if you're in a browser, (enable-console-print!) should fix it
does anybody understand the rationale for the "env" half of the dispatch value of cljs.test/report
?
@angusiguess : fixed it; thanks!
e.g., a use case where changing the env is a better way of doing something than anything you can do in jvmland-style?
I'm trying to figure out the best way to address this issue: https://github.com/gfredericks/test.chuck/issues/52#issuecomment-271313365
@gfredericks In general the reporting mechanism is fragile. I use it in Cursive to provide the test integration, but things like humane-test-output break it.
I don’t have a good solution unfortunately - I’m considering hooking the default reporting mechanisms, reporting in some out-of-band way (over a socket to the IDE, or something), and then calling the original methods to ensure everything stays working.
I think for my problem (something called karma uses a nalternate env keyword) it would work if karma had its env extend the default, in the namespaced-keyword-inheritance-hierarchy-thing