This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-11
Channels
- # admin-announcements (26)
- # aws (1)
- # beginners (356)
- # boot (28)
- # cider (20)
- # clara (12)
- # cljs-dev (78)
- # cljsrn (22)
- # clojure (333)
- # clojure-brasil (1)
- # clojure-dev (15)
- # clojure-miami (1)
- # clojure-nl (3)
- # clojure-russia (61)
- # clojurecup (3)
- # clojurescript (137)
- # clojurex (4)
- # core-async (4)
- # data-science (3)
- # datavis (2)
- # datomic (31)
- # editors (1)
- # emacs (9)
- # hoplon (3)
- # juxt (8)
- # ldnclj (47)
- # leiningen (4)
- # luminus (4)
- # off-topic (20)
- # om (332)
- # onyx (1)
- # parinfer (23)
- # portland-or (4)
- # proton (161)
- # reagent (46)
- # ring-swagger (11)
- # specter (7)
- # yada (2)
How do you use regex in cljs? How would I translate /notes/gi
into something like (re-find)
?
Cannot point you to some resource but cljs regex follows the Clojure rules...with little differences, for instance "/" is not a special char (if I remember correctly)
@tom:
cljs.user=> (re-find #"notes" "hello here some notes for you")
"notes"
Is that what you want?@jindrichm: I can do this on my comp with Java 8, so it should work
@rasom: OK, thanks. I probably have a different problem then. EDIT: Updating to lein-cljsbuild "1.1.1" solves it.
@rauh: just tried to compile simple example with and without DS. 310k → 498k raw, 78K → 118K gzipped
I’m not sure how much of this is shared CLJS core functions, because DS uses a lot of these
How can I declare a global variable with clojurescript?
//global variable
globalName = "JavaScript Interop";
globalArray = globalArray = [1, 2, false, ["a", "b", "c"]];
@juhoteperi: hey, I saw you packaged selectize for cljsjs, and I was wondering if you by accident know if there you need to do anything special to get the typeahead/text completion to function in Reagent
sort of the code I have now https://gist.github.com/joelkuiper/0b970745cda78de007a0 I pass in options and defaults as the options param, but no typeahead!
@joelkuiper: Sorry, I didn't package it originally. You should probably debug if the problem is with JS or CSS, check with dev tools if selectize elements are being created.
Also, instead of creating input with id using set inner html, it's much easier to just create input with id with react: [:div [:input {:id id}]]
yep, bit of a legacy issue when I was fiddling with it
I guess the problem is that it lacks the sifter dependency
https://github.com/brianreavis/sifter.js or at least, that’s my hunch
@joelkuiper: Cljsjs package uses standalone version so shouldn't be needed
@joelkuiper: Check if update-selectize!
sees the input created by selectize!
yep the whole thing works, with the prepopulated options, except typing doesn’t do anything
i guess I can check if the onType fires
welp the onType event gets fired
hmm weird, I guess I can go without the typing functionality for now. Sifter does get included in the source as you say
but I still can’t get the type to work, probably some weird interaction between google closure/reagent/jquery and selectize
but nothing in the console that would indicate that
I know it’s a longshot seeing as Java != Javascript, but is there a way to execute clojure code from my cljs webapp without having to go over http with compojure?
Google says macros, but common sense tells me I can’t just change defn to defmacro and declare victory
re:selectize, it was my own fault for not reading tfm, if you change the label/id fields you need to also pass in searchField https://github.com/brianreavis/selectize.js/blob/master/docs/usage.md
@snowell: well not at runtime, since you don’t have access to the JVM on the browser or NodeJS. With macro trickery you can get clojure code to execute at compile time though
also you can share code between Clojure and ClojureScript with cljc and reader conditionals, if that’s what you’re after
if you really must execute JVM code in the browser, I guess you can go the old fashioned way with Java Applets 😉
@joelkuiper: I was trying to look into cljc but it didn’t seem like I was going to be able to bring in Java objects and mess around with them
nope, if that’s your goal then I guess the only options would be Java Applets, or doing a round trip to the server
the latter is probably preferred in the current ecosystem 😉
Round trip is what I’m currently doing, but the machine I’m hosted on has pretty bad latency
although I’m still predicting a revival of applets in the near future 😛
Trying to use with-redefs
with cljs.test
but it doesn’t seem to be working. Does with-redefs
work in ClojureScript?
Hi guys, I'm having some troubles making my uberjar finding static resources (mainly the index and compiled js file). I started from a re-frame template to which I added a compojure/http-kit backend. Can anyone point me to a guide? Thanks a lot!
@doddenino: are you using wrap-resource ?
if so, we use something like this
and then we put :resource-paths ["resources" "generated”] in the project.clj also
so all generated resources go to the “generated” directory and that’s included in the jar
@joost-diepenmaat: No, I'm not using wrap-resource. Do I have to?
@doddenino: if you’re running from a jar, you have to serve all statics as resources instead of files
so if you’re currently using wrap-file, that won’t work in a jar
if you’re using ring-defaults, that includes resources I think. see https://github.com/ring-clojure/ring-defaults
though the documentation for ring-defaults is very terse and I tend to just look at the implementation
@joost-diepenmaat: I have a (route/resources "/")
route, my js is outputted to resources/public/js/compiled
and I have a :resources-path "resources"
in my project.clj. I'm not using ring-defaults
I think that should work
does it work when running from the repl instead of in a jar?
as far as I know everything in resources will be included in the jar and should be accessible
you could unzip the jar to see if the files are there
but it seems like it's looking for resources outside of it. For example, if I put the jar in a different folder it complains that it can't find the index.html file
I don’t know. I’ve had trouble configuring all of that before but I can’t really remember what the problem was then
Just one last question: If I have different cljsbuild builds (let's say "dev", "test" and "min"), how can I choose which one has to be used with lein uberjar
?
I think you can use an “uberjar” profile
or not. I forget. sorry I have to go.
they will happen one after another so that’s strong enough guarantee to write something simple that works for you
I'm using its ClojureScript router, set-location!
and :navigate-to
to translate back and forth between URLs and app state mutations. So when the URL changes, :navigate-to
triggers the mutations necessary to make my app state reflect the URL. I use set-location!
from my app to translate the app state to a URL that is then set. However, with URL patterns like /foo
and /foo/:x
it seems this only works in one direction. So it matches /foo
to {:handler :foo}
and /foo/13
to {:handler :foo :route-params {:x 13}}
when calling :navigate-to
. But it translates both {:handler :foo}
and {:handler :foo :route-params {:x 13}}
to {:handler :foo}
in set-location!
, which is wrong. The order in which routes are defined may play a role but I'm not sure how it's done right.
@jannis try pinging @jonpither or @malcolmsparks
@agile_geek: Thanks, looks like you've done that for me. 😉
@jannis: what do you mean by translating {:handler :foo}
and {:handler :foo :route-params {:x 13}}
to {:handler :foo}
? Do you mean using path-for
or am I misunderstanding something?
@jaen: I mean that calling set-location!
(https://github.com/juxt/bidi/blob/master/src/bidi/router.cljs#L72) with those two inputs leads to :navigate-to
to be called with {:handler :foo}
both times, and the URL to be set to /foo
both times.
It's quite cool. :navigate-to
to react to URL changes, set-location!
to feed changes into the router. Done.
But interesting it looses the params, from the code it looks like location->token
does almost the same path-for
does, and that worked for me.
It might actually work with my examples. My routes are a big more complicated than that.
@jannis 😄 of course now Malcolm and Jon won't talk to me again
/[#"[^]*" :state]/requirements
and /[#"[^*]" :state]/requirements;[#".*" :names]
is what they look like (not a bidi notation ;)), and I'm mapping them both to the same handler (`:requirements`).
@agile_geek: Ha, I hope they will
bidi seems to have support for multiple routes matching the same handler, according to https://github.com/juxt/bidi/blob/master/src/bidi/bidi.cljc#L443:
;; If you have multiple routes which match the same handler, but need to
;; label them so that you can form the correct URI, wrap the handler in
;; a TaggedMatch.
@jannis: with ring if you use keyword you have to specify a function that maps the keyword to a handler (you can make use of map specifying IFn if you don't need more than a simple lookup) and I assumed this router has a similar parameter.
But from the docs it seems like this is supposed to work when you specify handlers as functions, not as keyword - https://github.com/juxt/bidi#tagged-match.
@jaen: No no, you're making a good point. It might work even without function handlers as well: ... {"requirements" {"" (tag :requirements :all-requirements) [";" [#".*" :names]] (tag :requirements :specific-requirements)} ...
.
hi, is this possible in clojurescript to make functions implement custom protocols like in clojure ?
@leonoel: at the cost of interop, you can make callable objects but JS won’t understand them
@dnolen yes that solution could work for me but I was trying to port a clojure code that was an extend-type of clojure.lang.Fn
@bhauman: Hi, if you have some time, I raised an issue for prismatic schema in combination with figwheel. Maybe you could have a look at it and see if this could be figwheel related? This is the uri: https://github.com/Prismatic/schema/issues/315
For REPL lovers, we released a new version on http://clojurescript.io that should be way faster. The following tweaks were combined in order to shred the app size (no modules yet):
Added elide-asserts flag (~100KB less)
Added dump-core flag (~2MB less)
Filtered unused symbols from cljs_api (~500KB less)
In addition to the :optimize-constants and :static-fns flags the total size of cljs-repl-web.js decreased from 9.9MB to 4.7MB
it was in answer to @mfikes video: https://youtu.be/9k6Z3GTai6c (thanks Mike :))