This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-05-05
Channels
- # admin-announcements (4)
- # beginners (47)
- # boot (69)
- # cider (11)
- # cljsjs (1)
- # cljsrn (5)
- # clojure (163)
- # clojure-austin (17)
- # clojure-russia (27)
- # clojure-uk (46)
- # clojurescript (109)
- # core-async (28)
- # cursive (2)
- # data-science (1)
- # datavis (1)
- # datomic (9)
- # dirac (33)
- # funcool (8)
- # hoplon (1)
- # lein-figwheel (1)
- # leiningen (1)
- # luminus (23)
- # mount (3)
- # nyc (2)
- # off-topic (25)
- # om (3)
- # onyx (4)
- # perun (7)
- # re-frame (10)
- # reagent (2)
- # ring-swagger (4)
- # spacemacs (4)
- # uncomplicate (1)
- # untangled (21)
- # vim (2)
- # yada (2)
I’ve just noticed there is defmacro
in cljs. Is there a document how to use it properly?
nvm, I found this https://groups.google.com/forum/#!topic/clojurescript/HINltkZ_NuM
@danielcompton I have wanted to potentially make use of defrecords but I dont know of a particular where it would shine over say using functions and maps of data. For what scenarios do you find defrecords a good fit?
@sbmitchell: this is pretty good explanation https://github.com/plumatic/eng-practices/blob/master/clojure/20130926-data-representation.md
thanks
Is there a way to make closure compiler break up methods so none of them are over 64k compiled? I'm trying to target rhino and currently only :optimizations :advanced will work, but the rebuild time on that prevents a good development experience
alternately, if i could precompile the entire clojurescript library with :optimizations :advanced in advance and then have the rest of my code use :whitespace that would work. i don't need the dead code elimination features at all
In ClojureScript, is it possible to use the #my.thing[1 2 3]
or #my.record{:a 1, :b 2}
reader forms that are documented in http://clojure.org/reference/datatypes? I’m having difficulty using them.
Ah, looks like no, unfortunately: http://dev.clojure.org/jira/browse/CLJS-1328
I’m having trouble understanding the relationship between lein-figwheel and Figwheel Sidecar - can anyone explain?
@jonoflayham: lein-figwheel is lein plugin, and figwheel-sidecar(and also figwheel) is figwheel system.
I passed an atom: (defonce tasklist-atom (atom {:entries []})) to om/root function: (om/root tasklist tasklist-atom {:target tasklistel}) Now I can retrieve the atom content inside component constructor like this: (seq (:entries @tasklist-atom)) or (seq (:entries tasklist-atom)) . It should be an issue that I can retrieve the atom content via: (seq (:entries tasklist-atom)) right? Component Constructor Code Example: (defn render-tasklist [state owner {:keys [counter] :as local}] (println (seq (:entries state))) ;; print ({:subject "a", :id 2, :completed false}) (println (seq (:entries @state))) ;; print ({:subject "a", :id 2, :completed false})
@xfcjscn: from Om's docs: "During the render phase, you treat a cursor as a value, as a regular map or vector. " https://github.com/omcljs/om/wiki/Cursors
@anmonteiro: Thanks a lot. I didn't go through the doc carefully.
Hey, how would I go about catching errors involving XmlHttpRequest
?
can’t transfer this knowledge to cljs http://stackoverflow.com/questions/26756752/how-to-catch-errors-involving-xmlhttprequest
sorry I asked this before, but how does one cljs.js/eval forms that refer to functions in other namespaces ?
@ajchemist thanks!
@urbanslug: the second answer there by Francois Dermu is how I'd go about it: I'm not 100% sure about this, but I wouldn't expect, e.g., goog.net.XhrIo
to throw exceptions, but rather just return a status code, which your cljs code responds to. Are you actually seeing exceptions being thrown by XmlHttpRequest or anything else in JS?
(I'm sure someone has but I'm mildly surprised I haven't bumped into any discussion of it)
Dirac would be a real-world example: https://github.com/binaryage/dirac
@darwin Wicked cool. Thanks. I had seen the devtools repo but I must have misunderstood something and took it as not a chrome extension.
cljs-devtools is just a library with some hooks into DevTools console (it does not need Dirac)
definitely look into https://github.com/binaryage/chromex, cannot imagine starting a new chrome extension project without it
awesome. I have historically avoided a lot of JS stuff just because I am not a fan of the language, but since finding cljs I have been looking around at a lot of areas that I had previously not dove too deep into, and the other day at work I found myself wishing for a chrome extension.
you should be familiar with core.async, chrome apis are mostly async, you will be writing code spiced with a lot of go blocks, I guess (an example https://github.com/binaryage/dirac/blob/master/src/background/dirac/background/tools.cljs)
Hello guys and gals, I’m a bit confused why this is returning true
(number? (js/parseInt (last "123x")))
js/parseInt returns NaN which is Not a Number, but clojurescript says it is….
All I want to do really is to see if the last character in a string is a number, maybe there is an easier way
so how could I figure out if the last character is a number or not?
I think (js/isNaN n)
is what you need
Since the only numeric available in JS is double-precision floating point, NaN (as a valid double-precision floating-point) will make number?
true
ah, ok… I’ll try that
@victorbjelkholm: regexp?
to see if a number is a NaN
parseInt would return an Integer or NaN so sounds reasonable
@fasiha: I’ll try everything I can to not do regex 😉
blissdev: didn’t know, not a requirement from me though
I'd prefer (re-matches "[0-9]" (last "123x"))
. Makes it obvious what you're doing instead of complexting language specifics. Parsing to number and checking for NaN is much less obvious. Plus it'll work in Clojure when you want to share code.
base don the standard it should be a number
4.3.24 NaN number value that is an IEEE 754-2008 “Not-a-Number” value
fasiha: maybe, if you’re coming from clojure and are gonna write serverside and want to share. In this case is just the frontend and coming from a javascript background
@bwstearns: Right, and also (== NaN NaN)
is false
No matter how much sanity cljs brings to the fight, js will always bring more insanity.
I think JS engines implement isNaN by checking if x==x
because NaN is the only thing (so far) for which x!=x
@bwstearns: again, it's a floating point, IEEE 754 thing. All languages that use floating point will have those semantics.
@bwstearns: But NaN
is a number, even though its name would lead you to believe otherwise. Clojure is the same: (number? Double/NaN)
yields true
@fasiha @mfikes But JS seems to be the only language that I run into NaNs frequently.
Thats why we there are standards 😛 to make the counter intuitive "clear"
Yup: in Clojure (= Double/NaN Double/NaN) ; => false
too welcome to the world of floating-point! FYI, John Gustafson has described a
unum
alternative to floating-point which will solve most of these problems: http://ubiquity.acm.org/article.cfm?id=2913029 I believe there's a Java port too (and we'll hopefully get hardware support in a few years)
What @bwstearns says makes sense tho: I feel that I do run into NaN in cljs more than Clojure. Is that just because of parseInt?
I think it's just more javascript-y to actually return NaN as a result so they end up getting passed around and pop up several layers later where numbers (real numbers, that you can do math with, you know what I mean) were expected. btw I didn't mean to wholly sidetrack the discussion from the initial topic but it does seem like a regex might be the easiest?
do you need interop or not?
rather clj + cljs solution I mean
seems fine I suppose. I try to avoid regex in most instances but to each his own
some?
is more idiomatic than (!= nil …)
I think? @bwstearns
re-find returns a boolean?
nvm no it doesnt
yea but I thought it returned a boolean 😕 heh still have to do something like (nil? (re-find ..))
I would probably just stick with the regex 😛
true. although other than feeling silly about typing [0-9] (a substantial barrier for recommending using the literal) I'm not sure how bad occasional literals are like that. If you were to change your mind about which characters should return true for this whole contains, you'd still need to modify the regex.
@victorbjelkholm: checkout goog.string/isNumeric
@jr: ah, that’s even more helpful, thanks a lot
@bhauman: Tested my Reagent project with the latest Devcards commit and it works, probably the problem was fixed by: https://github.com/bhauman/devcards/pull/100
@juhoteperi: cool, I'll get a release out pronto