This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-05
Channels
- # aatree (2)
- # admin-announcements (15)
- # announcements (2)
- # aws (8)
- # beginners (160)
- # boot (290)
- # braid-chat (28)
- # cider (8)
- # clara (1)
- # cljsrn (3)
- # clojure (154)
- # clojure-czech (7)
- # clojure-russia (162)
- # clojurebridge (2)
- # clojurescript (128)
- # cursive (29)
- # datomic (30)
- # emacs (7)
- # events (1)
- # hoplon (5)
- # jobs (1)
- # ldnclj (7)
- # leiningen (3)
- # off-topic (11)
- # om (82)
- # onyx (68)
- # overtone (1)
- # parinfer (57)
- # portland-or (1)
- # proton (18)
- # re-frame (8)
- # reagent (32)
- # ring-swagger (3)
- # yada (5)
There's now hope for creating libraries for nodejs in clojurescript. Check out https://github.com/crocket/cljs-npm-template
If you want to publish your npm library in clojurescript, you might want to publish it to clojars. Clojurescript npm libraries can be imported from clojars without the issue of multiple clojurescript runtimes.
Any way to use an URL route prefix with bidi? I.e. /#/my-route
instead of /my-route
.
Silk vs Bidi?
I use bidi, am satisfied. Though I heard silk is nice, just didn't have any chance to try it out so far.
Maybe a bit of a downside to bidi is slightly unreadable route definitions at times. I quite often tend to miscount the parens I need.
Also as I mentioned on boot, hash-fragment is something you should handle before reaching bidi IMO. Use the hashchange
event and then dispatch to bidi.
@jaen Do you use hashchange
as a substitute to the goog.history
machinery, or in addition to?
Hah, no, I use HTML5 history API; but since the question was about #
it's what I suggested.
can someone tell what's broken with this regex #"application\/vnd\..+\+json"
?
@martinklepsch: "application/vnd.test+json".match(new RegExp("application/vnd\..+\\+json"))
seems to work if that helps; I guess Clojurescript reader interprets \+
as a string escape and resulting string is invalid?
I also think \/
is not needed unless you use a regex literal like in Javascript or Ruby. That is unless Clojurescript's regex literals compile to them, but I assume they compile to new RegExp(...)
@jaen: sorry, that was a bit of a brief problem statement
(re-find #"application/vnd\..+\\+json" "application/vnd.test+json")
— I'd expect this to match but instead it returns nil
(re-find #"application/vnd\..+\+json" "application/vnd.test+json")
instead of (re-find #"application/vnd\..+\\+json" "application/vnd.test+json")
note double \\
huh, now I'm confused
I thought I've tried a single slash but apparently not with that version — fixed it, thanks! @joost-diepenmaat
you’re welcome
you should only need double backslash for escaping backslashes in regex literals
so for matching literal backslashes
yeah that’s what the #”…” syntax is for
otherwise you have to first escape backslashes in a string literal and then again for the Regex constructor
#”\n” should work for that
IIRC \n is interpreted as a literal newline character in strings and in regexes
yes it’s smart enough to do it correctly. as long as you don’t think about it too much it works
(java.util.regex.Pattern/compile "\\\\") #"\\"
AFAIK there are only a few special escapes in string literals; \\ \n \r and a couple more. Those all work in regex literals as is. The other special backslash escapes for regexes can also be used directly in #”” syntax.
In JVM clojure things like “\+” are invalid in a string literal, and only work in #”…” syntax
That makes sense, I suppose; didn't have to write much regexes in Clojure so far, so didn't know all the details
Tomek, do you have like a photographic memory or something? You're like an encyclopedia of programming knowledge. Or a set of encyclopedias. Seriously. Damn.
I don’t know if there’s a Clojure equivalent, but AFAIK regexes in Clojure/ClojureScript are quite similar right? If so, http://rubular.com is a nice tool to use while building regexes. I use it to build JS matchers as well. Thought I’d drop this in
@mull: It's pretty cool, but Ruby's expression are PCRE, so they are strictly more powerful so it's something to keep in mind.
Java8 added them I think, but IIRC Clojure has no support for them in re-find
(that is, you get just a vector, not a map.
True, I guess I never considered it. I rarely write anything else than the most simple of patterns
Also, while we're at it, https://www.debuggex.com/ and https://regex101.com/ are also very useful websites when writing regexes.
And yeah, I agree regexes shouldn't be too complex if possible. The RFC-compliant email regex is an abomination for example.
I love how Haskell guys decided to do that with PEGs instead - https://hackage.haskell.org/package/email-validate
@jaen we have something quite similar with instaparse, although this particular lib won't work in clojurescript. Ex. for e-mails : https://github.com/sfx/schema-contrib/blob/master/resources/email.abnf
@nha: oh, nice someone took the right idea. Also, I think I've seen instaparse-cljs somewhere. Not sure if it could deal with this grammar though.
But I usually just do it login + at sign + at least tld style rather than 100% conforming to the RFC.
Yep, that's probably the smartest move anyway. I think for example that not all gmail logins are RFC-valid for example (you can do ..
in the login which is RFC noncompliant, but gmail ignores dots in the login).
Oh I did not know that. I use <mailto:[email protected]|[email protected]> quite often, and I am not even sure it is valid, or if some validations in the wild validate only a subset of valid mails.
Oh, pluses are valid, as is this #!$%&'*+-/=?^_
{}|[email protected]` for example, but double dot for some reason is not.
But yeah, websites validating mails or RL addresses that are valid because they work is vexing; so it's probably best to not get too overboard on that. At best just issue a warning or something.
@nha: if you're interested in some examples of valid/not valid here are some test cases from an RFC-compliant validator - http://isemail.info/_system/is_email/test/?all
Here is what I use (re-find #"^[^@]+@[^@\\.]+[\\.].+" e)
but I certainly did not write it. Until recently I was just checking that there was an @
.
Yeah, basically what I use as well; though if one day someone with an email in a TLD would want to register, they would be surprised xD
What are the top recommendations for cljs UI libraries? I'm using react, reagent, reframe, and I've had a nightmare trying to get cljsjs's react-bootstrap
and react-mdl
working...
My thinking is a good way to avoid nightmares is to go with libraries that don't use js - where all the code is in cljs. re-com and reforms are examples. re-com uses Bootstrap css and the rest is written in cljs I believe.
yes re-com is cool I have used it for http://clojurescript.io 😉
@cjmurphy: If I go the cljs route, does that mean I really shouldn't plan on js interop?
That's a hard question. More experienced people here. It is the wrong time for lots of activity. Weekend and most asleep.
oh geez, you're chris from http://stackoverflow.com/questions/35232945/in-clojurescript-how-do-i-properly-use-cljsjs-react-mdl, thanks so much for being my guide in all this! I feel converted to clojure, just a bit overwhelemed with learning the whole new ecosystem! It's cool to know there's a clojure support group
But you can combine all things. Say if you really wanted a js date picker (there's one in re-com by the way) you could use it via Interop.
@josh.freckleton: well, it's not that hard to combine Clojurescript and Javascript. For example take a look at this gist - https://gist.github.com/jaen/7123aa5f7e15dccbed28 - it combines reagent with Semantic UI's dropdown.
Yes you will get plenty of help here, especially for particular problems. Big issues and general questions about 'what is the best' can be tough. As you know at the moment I'm going with Semantic UI. Great - Jaen's here!
@jaen: thanks jaen. CJMurphy had just made a couple recommendations over bootstrap
/`material` for getting UI components into a react/cljs app, have you been having pretty good experiences with Semantic UI? Any other suggestions?
Right now I've used only the dropdown, but it was pretty painless. You can look at links in this issue - https://github.com/gadfly361/soda-ash/issues/1#issuecomment-174381692 - for more context.
Semantic UI components seem to be written in a way, that makes integration with React relatively simple.
I tried to do a tabbed pane kind of thing with MDL and it was tough to do - all kinds of unnecessary code - compared to same thing with Semantic UI - so I went back.
If you want material look&feel specifically then this seems pretty kewl - http://www.material-ui.com/#/
It would be pretty tough to integrate with Clojurescript (it's CommonJS modules) but someone already did the hard work - there are both om and reagent compatible libraries for it.
(by pretty tough I mean: using webpack/browserify as an additional build step to compile the modules out; it's not hard per se, just vexing)
This is the one I had troubles with: http://www.material-ui.com/#/components/tabs
You can try this - https://github.com/tuhlmann/reagent-material - for reagent and this - https://github.com/taylorSando/om-material-ui - for om prev.
Just I couldn't read the examples so easily. Although now I like your one better - at least you don't have to do two sets of tabs and tie them together - which was my main problem.
@jaen the integration of Semantic UI and reagent is straightforward, I wonder if these components can be contributed to soda-ash
(I have been pondering this in the last two days for a project of main, choose Semantic UI instead of re-com and contribute components back)
Yeah, it is, at least from what I can tell. Liked I mentioned they seem to have paid some attention to integration with React.
So a first pass on those components could be just wrapping of existing jQuery components
true that
@josh.freckleton: For react.mdl all the objects are behind window
(ex. window['MaterialCheckbox']
https://github.com/tleunen/react-mdl/blob/master/extra/material.js#L701 ). But I use semantic.ui now as well (even though I submitted react-mdl
to cljsjs), following advice from cjmurphy.
@nha: awesome, I'll probably end up trying out Semantic! In the mean time, any idea why this is throwing an error?:
(ns project.views
(:require [cljsjs.react-mdl]))
(def Button (aget js/ReactMDL "Button"))
how should I use your information about the objects being behind window
?Honestly at the time I thought I had got it wrong - that Material UI was a made up conflation of Semantic UI and Material Design. But as Jaen shows it really exists.
@josh.freckleton: I replied on SO, hope it makes sense
you could try MaterialButton(element)
for instance in the brower console to check the import worked
Agree with you @cjmurphy, unless you need ready-made components (like datatable in react-mdl, or some fancy dropdown maybe)
Hmm - but I would have had an easier time of it with the tabbed pane thing - because it must have been the Javascript that meant not having to double up with all that html.
Interesting thing is Semantic UI tabbed pane is only css - and no need to double up on the html. So seems like it is of smarter design.
Yes, being pure css is definitely a plus. Maybe there will be a om-semantic-wrapper at some point for the more dynamic components, in the meantime I'm happy with semantic.
Does someone have opinions on https://github.com/JulianBirch/cljs-ajax versus https://github.com/r0man/cljs-http ?