This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-16
Channels
- # aatree (1)
- # admin-announcements (6)
- # alda (3)
- # beginners (66)
- # boot (41)
- # cider (4)
- # cljsjs (3)
- # cljsrn (18)
- # clojure (146)
- # clojure-android (2)
- # clojure-nl (1)
- # clojure-russia (35)
- # clojure-sdn (2)
- # clojure-sg (5)
- # clojure-uk (41)
- # clojurescript (116)
- # datomic (12)
- # dirac (40)
- # docker (2)
- # editors (2)
- # hoplon (85)
- # immutant (19)
- # jobs (1)
- # keechma (2)
- # lein-figwheel (8)
- # mount (33)
- # off-topic (1)
- # om (114)
- # onyx (159)
- # parinfer (24)
- # proton (3)
- # reagent (4)
- # ring-swagger (15)
- # uncomplicate (7)
- # untangled (93)
- # yada (30)
Should goog.array.binarySearch
be behaving like this, in a cljs repl?:
cljs.user=> (goog.array.binarySearch [1 2 3] 2 compare)
-1
cljs.user=> (goog.array.binarySearch [1 2 3] 5 compare)
-1
Basically, no matter what the second or third argument is, it seems to return -1.I will now see if subvec
/`rsubvec` are faster or slower than (goog.array.binarySearch (clj->js v)…
Just trying to get a feeling for these magical Clojure/Script data structures. Vectors that are implemented with trees, and other apparent absurdities 😄
Hey all, I'm stuck on the right way to get the google maps API. I've got it in my deps (https://github.com/BWStearns/hrbr/blob/master/project.clj#L41) and I think I'm requiring it properly (https://github.com/BWStearns/hrbr/blob/master/src/cljs/hrbr/comps.cljs#L7) but I'm still getting clojure.lang.ExceptionInfo : No such namespace: cljsjs.google-maps, could not locate cljsjs/google_maps.cljs, cljsjs/google_maps.cljc, or Closure namespace "cljsjs.google-maps"
I see the github page (https://github.com/cljsjs/packages/tree/master/google-maps) says "The Google Maps js API will still need to provided through some other mechanism" but I'm not sure if that's what I'm running into or what that other mechanism would be. Sorry to bug everyone with a dependency problem (I know code problems are more fun).
@bwstearns: Since Google Maps is externs only it does not provide any (fake) namespaces to require
I'm not entirely sure about this but I think just including the dependency will include the externs in compilation
@bwstearns: also just to make sure: you will still need to load the google maps JS API on your own — since these files are dynamic they cannot be packaged as a CLJSJS package
@martinklepsch: "does not provide any (fake) namespaces", what do you mean by fake namespaces?
So does that mean that I should just have <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> in the HTML?
Most other CLJSJS libs provide a fake namespace like cljsjs.react
that will (if you require it) add the react code to your build. Since this is not a real namespace/closure module you will still access it via js/React
— that's why I called them fake namespaces
@bwstearns: yes, for google maps something like this is necessary.
@martinklepsch: ok, and then I can just access that in cljs files with something like js/google.maps.mapFoo
?
@martinklepsch: thanks for the help and the explanation
> ok, and then I can just access that in cljs files with something like js/google.maps.mapFoo
?
yes
sorry didn't see the earlier message @bwstearns — did you get it working?
My goal: Construct a ClojureScript function that takes a string s
and returns the unique channel with the name (str s "-chan")
(if the channel doesn't exist, then create it). Here is my attempt:
(defn string-channel
[s]
(let [chan-name (symbol (str s "-chan"))]
(defonce chan-name (chan))
chan-name))
This yields an error. How do I accomplish this goal in cljs (without the use of eval
, etc)?@george.w.singer: You’ll need to use a macro. (defonce chan-name (chan))
will create a var named, literally, chan-name
.
Ok. Here is my attempt. I'll see if it works
(defmacro string-channel
[s]
(do
(defonce ~(symbol (str s "-chan")) (chan))
~(symbol (str s "-chan"))))
in any event: I get error "first thing to def must be a symbol"
you want to quote the (defonce…) expression
`(defonce ~(symbol (str s "-chan")) (chan))
or even the whole (do … ) expression.
but since you’re not actually using the name directly, you could also store all the chans in a map in an atom
and then you don’t need a macro
(defonce channels (atom {}))
(defn string-channel [s] (swap! channels update s (fn [existing] (or existing (chan)))) (channels s))
or something like that
@urbanslug: See "async testing": https://github.com/clojure/clojurescript/wiki/Testing
@joost-diepenmaat: quoting the do
block worked
@joost-diepenmaat: any reason to prefer the atom solution? Is is it just avoiding macros, which can be a pain in clojurescript?
@george.w.singer: Seems easy enough
mostly because macros are a pain
but also adding random vars in the namespace is a bad idea
@urbanslug: here is a template I often use for async testing:
(deftest <fn-TEST
(async done
(testing "Optional description of test."
(go
(let [input-data "Input data for <fn you are testing."
expected "Expected value of your <fn"
actual (<! (<fn input-data))]
(is (= expected actual)))
(done)))))
Where <fn
is a function that returns a channel
I m looking for a material design templates. I am new to building website and I like clojure/clojurescript and react-js caught my eye. (re-frame) can anyone point me to a good templates I can easily add to my site
What's the difference (in use) between into-array
and to-array
? They look to me like they do the same thing with different implementations.
Ah, it looks like into-array
is for seqs, and to-array
is for collections. Is that right?
(extend-type js/Rx.Subscription
cljs.core/IFn
(-invoke [this]
(.unsubscribe this)))
I'm doing something evidently wrong but I don't see it 😞
This code raises Caused by: java.lang.UnsupportedOperationException: nth not supported on this type: Symbol
exceptionDoes anyone have any experience with figwheel name collisions between server and client files?
I have a server build and a client build (with figwheel hooked up to the client build). Namewise, they both have the same entry point: name.core
; however, this is purely nominal: the server files and the client files are completely separated via their cljs-build
:source-paths
fields (i.e., the server files are within src/cljs-server
and the client files are within src/cljs-client
.
Nevertheless, when I try to connect figwheel the client, I get an error having to do with a server file!
The only way I have figured out how to fix this is to rename the :main
entry point on the client side to something different than the server side (i.e., I'm using name.core-client
on the client side and name.core
on the server side).
How does figwheel have any knowledge of these server files?
@george.w.singer: if these two paths are on :source-paths
their contents are next to each other on the classpath
@martinklepsch: What do you mean?
@george.w.singer: lets say you have src/cljs-server/name/core.cljs
& src/cljs-client/name/core.cljs
when adding src/cljs-server
and src/cljs-client
to :source-paths
the files in them overlap relatively to their source-path root (both will be added at name/core.cljs
)
Yes, but the client build and the server build have different :source-paths
:cljsbuild { :builds {
:cljs-server-none {
:source-paths ["src/cljs-server"]
:compiler { :optimizations :none
:target :nodejs
:output-dir "out/out-cljs-server-none"
:output-to "target/cljs-server-none.js"
:verbose true
:main name.core
:pretty-print true }}
:cljs-client-none {
:source-paths ["src/cljs-client"]
:figwheel true
:compiler { :optimizations :none
:asset-path "js/compiled/out-cljs-client-none"
:output-dir "resources/public/js/compiled/out-cljs-client-none"
:output-to "resources/public/js/compiled/cljs-client-none.js"
:source-map-timestamp true
:verbose true
:main name.core
}}
So there shouldn't be a name collision, right?
@dnolen: is strangelly happens only with IFn, if I replace in the same example IFn with IDeref, the code compiles without problems
@george.w.singer: these source-paths mean something like "put the contents of these directories on the classpath"
The classpath can be thought of as another directory (simplified)
So distinct source-paths in the project.clj are just an illlusion
They are still all being piled onto a single classpath
If so, that is deeply confusing
There could be all kinds of name collisions within a full-stack project
That's true and I agree that it's confusing
Potentially tools (Lein/Boot) should print a warning if theres a clash between the files in the provided source-paths
Fair enough.
At least I understand where this error is coming from (thanks for your help). A _client.cljs
naming convention on the client-side files will fix this issue in the short-run.
Or perhaps renaming to src/cljs-server/name_of_project/core.cljs
and src/cljs-client/name_of_project-CLIENT/core.cljs
i.e., renaming the client folders
nice, issue filled: http://dev.clojure.org/jira/browse/CLJS-1602
@george.w.singer: I'd suggest the following: src/name/server/core.cljs
+ src/name/client/core.cljs
@george.w.singer: but of course either approach will work
@martinklepsch: so many folders! Is one answer generally more idiomatic here (i.e., yours)?
I have an obvious dependency-related issue that I'm trying to track down. On certain builds I get " No reader function for tag object" during cljs analyzer when invoking the reader...any thoughts?
@martinklepsch: I got it almost working, sorry for the delayed reply, but it was super late where I am so I ended up grabbing some sleep haha. It's good in that now I have a new problem but I think it's still rooted in my misunderstanding of js/cljsjs dependencies. Either I get no errors and nothing happens or I end up with some variant of TypeError: Cannot read property 'call' of undefined
Cannot read property 'call' of undefined
is reported when you end up doing something like (some-fn arg1 arg2 …)
and some-fn is bound to null during runtime
you might try to use cljs-devtools with :sanity-hints enabled
to see more context for such errors in your console logs:
https://github.com/binaryage/cljs-devtools/releases/tag/v0.4.0
That looks like it could potentially cut down on the amount of late night cursing I do.
So maybe I'm trying to learn too many things at once. But I would like to figure out how these things are interrelated:
And now I'm confused about what it means to use Figwheel with a Node REPL and what CIDER would connect to
And I don't actually know what Figwheel does, I just saw it to cool things when I was trying out devcards.
Maybe I don't have a question. I'm just imagining a graph of a Node Repl, a Cider process, whatever it is that Figwheel does, and my server.js code, and wondering about the directions and names of the arrows among those nodes (sense #2)
Maybe I don't have a question. I'm just imagining a graph of a Node Repl, a Cider process, whatever it is that Figwheel does, and my server.js code, and wondering about the directions and names of the arrows among those nodes (sense #2)
I'm sure there is a way to do it, but the little clojurescript project I have is wired to just use the straight figwheel repl.
I just like being able to send forms in a source file to a repl to see if they do what I think they do.
I haven't really ever developed with anyone so, all my dev environments are basically feral outsider art~
I'm reading that over, and I'm amused by how much you have to know in order to get the kind of environment in which it would be great to learn the things that you need to know in order to