This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-16
Channels
- # aws-lambda (3)
- # beginners (20)
- # boot (201)
- # cljs-dev (45)
- # cljsrn (9)
- # clojars (19)
- # clojure (141)
- # clojure-china (2)
- # clojure-dev (11)
- # clojure-greece (6)
- # clojure-italy (1)
- # clojure-new-zealand (1)
- # clojure-romania (1)
- # clojure-russia (55)
- # clojure-spec (58)
- # clojure-taiwan (1)
- # clojure-uk (97)
- # clojure-ukraine (40)
- # clojurescript (77)
- # core-async (5)
- # core-typed (1)
- # cursive (35)
- # datomic (9)
- # jobs (2)
- # jobs-rus (25)
- # juxt (8)
- # lein-figwheel (14)
- # luminus (24)
- # mount (16)
- # off-topic (56)
- # om (36)
- # onyx (22)
- # pedestal (3)
- # perun (14)
- # re-frame (111)
- # reagent (5)
- # remote-jobs (6)
- # ring-swagger (3)
- # slack-help (1)
- # specter (17)
- # unrepl (12)
- # untangled (56)
How do you set an environment variable for a cljs project that will be picked up by this definition?
(defn get-sys-val [id] (or (System/getProperty id) (System/getenv id)))
Because those look like java methods. Which I guess the cljs compiler is running. I setting the variable in :closure-defines
and it didn’t work.
seantempesta you need to ensure that code is run by the java cljs compiler, and not the cljs runtime, which I think would mean putting the code in a macro, not a function
I compile environment constants into my shell.html via my server side rendering function
Yeah, it’s a macro that’s evaluating it. But how do I set the environmental variable in a lein project?
System/setProperty or use the specific non-portable version of setting an environment variable that works on your jvm/host combination
the environ library is pretty simple but sets up some good default ways to do this stuff
@noisesmith: Cool. I’ll check it out. Thanks.
docs says clj substring is O(1); is cljs substring also O(1) ? (writing a parser, trying to figure out if I can use subs or if I need to use a reader of some sort)
@qqq no idea about that but CLJ and CLJS both use the host String implementation. So I would look into what the JS String impl has to say about that, each JS-VM might even have a different implementation.
I don't know if subs in cljs is O(1) or not. Now, I want to check s :: js string i :: integer r :: js regexp I'm interested in: is regexp r matchable in string s starting at location i ? I know of String.match -- but that checks anywhere; I want to enforce it to start the match at location i, where "^" in the regexp would match location i of the string.
but i'm a little fuzzy on setting up for that -- I'm going to read up on lein-cljsbuild and figwheel for node, but I anticipate getting confused by which handles what
figwheel + node is so that you automatically run the compiled-to-js code when you make changes, but it's cljsbuild that sets options for that compilation?
is there any way to suppress namespace expansion of kws in macros? if my macro is passed ::foo, I need to get that instead of :my.namespace/foo. i don’t suppose there’s any easy way to do that?
@mobileink (keyword (name kw))
oops .. not what you asked ... you can look at *ns*
and fake it, but no.
@mobileink you can't do that since ::foo expansion is a reader-level construct
see for example (read-string "::foo")
same with #()
, #_
or any other reader macros
that's what i thought. 😦 but this is an opportunity for a dastardly post processing hack!
fwiw the task is to embed cljs in clojure, then emit the cljs to a file. is there a known way to do this?
Hey, is there any way you can just drop a cljs onto a script file and run it in the browser, like with babel and es6?
@samscript might be something in here http://clojurescript.net/
I mean I wanna use it right in the browser without using lein at all, is that possible?
cljs can self host, yes
I mean lein is just a build tool, you can also use cljs.jar directly with java, but there's a cljs.js, as qqq mentions
@samscript you mean sth like <script>(defn f [x] (println (str "hello, " x)</script>
?
@qqq eval-soup looks very useful, but it looks like it evals strings, not clj code.
@mobileink: how is that a problem? (eval-soup (with-out-str (pprint ...)))
also, see http://oakes.github.io/paren-soup/ <-- this is evidence you can just write code inside a div, then have eval-soup eval it for you
@qqq i don't see any <div> in that code. it looks like a bunch of clj/cljs code. where's the html integration?
@mobileink: https://github.com/oakes/paren-soup/blob/master/resources/public/index.html#L24-L35
@samscript: Self hosted clojurescript would probably be the way to go - though you will want the compile step in there before you bring it to production. What kind of thing are you trying to build with it?
@samscript working thru sth similar myself, you've been warned. 2 options: if you're using src="foo" in your script tag, you might as well precompile your cljs and pull in the resulting js. but if you want to support inlined/embedded cljs, you could (i think) run an in-browser cljs compiler and write js code to compile whatever is in your <script> elements. not tested, but makes sense to me!
@shaun-mahood : I'm currently making a SPA that's a wizard that lets you buy stuff. I want to do it with cljs
@mobileink: I think precompiling might not be a problem. I would assume it would be impossible to use reagent or other libraries the second way right?
@shaun-mahood I might start out real simple, re writing the carousel with cljs
just using cljs.jar and compiling to js for the browser is going to be easier than self hosting the compilation in the browser
@samscript: It seems odd to me that you can switch languages without a problem but the compilation step is a complete blocker. It really does a lot to reduce the size of your gzipped production file - so you'll probably be a lot happier if you can get that sorted out before you go live with anything.
But I'm also lucky enough that I don't have to worry much about language or tool politics - some companies seem to have some extremely stringent and not exactly logical rules.
@shaun-mahood: Well actually no, you can't really switch languages, that's why the compilation step is a blocker. That being said, everyone's smaller projects are their own, so if I have something that runs in the browser, it's not really a problem.
It's hard to explain the exact atmosphere, but if at the end of the day I can deliver without alerting everyone i'm doing a new language, that's idea
@samscript yeah, i think that's right. precompile gives you all the global optimization grooviness of the closure compiler. but i still think there's a place for inline cljs, if only for convenience and expressivity.
@mobileink I learnt that from the functional-tv guy. He recommended just getting the clojure jar files and sneaking it into the next build, since no one would likely notice one more jar file
I have a general architectural question: supposing you have, say, a car reservation system that needs to check three things (say, the nearest rental place to a user, car availability there, and discounts that may apply to the user) before returning a response to the client: how is that handled in a system like om next? It seems like a common om next style approach (although things like Falcor seem similar at first glance) is to have the same ball of state on the server and a subset of that in the client, kept in sync. But I'm used to firing off a request, having a sequence of things happen in succession with various outcomes, and returning that outcome to the client, which is updated. What do I need to think about to grok this properly?
then there's the third way, which is that you put cljs in your script tags in your html page, and then "compile" the page to generate and compile cljs files, and remove tbe script tags. this is what i'm doing.
@samscript do let us know what you come up with, please.
@mobileink For sure
another question: are you writing html, or using a clojure lib like hiccup to generate html? i guess either way the recommendation from @qqq, paren-soup, looks pretty promising.
does anyone have a guide for scripting atom in cljs ? I don't want to write my own editor from scratch; but I can't find how to script atom
@qqq: Might be something useful in either https://github.com/jasongilman/proto-repl or http://flight-manual.atom.io/hacking-atom/ - I think at least some of proto-repl is written in CLJS
@qqq atom is scriptable in js (they prefer to write their code in coffeescript), I ended up with a thin coffeescript glue code layer[1] and rest in cljs[2]: [1] https://github.com/darwin/plastic/tree/master/lib [2] https://github.com/darwin/plastic/tree/master/src/onion-atom/plastic/onion (at least this is how it worked 2 years ago)
I suspect I'm not the only person who wants an Atom where the ~/.emacs.d/init.el is written in cljs instead of elisp. However, this has not been done yet. Thus I'm guessing there must be some technical obstacle to this. Any one know what the limitation to "being able to use a 'cljs-Emacs' where elisp => cljs, and Emacs Gui => Atom" is?