This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-13
Channels
- # beginners (78)
- # boot (27)
- # cider (13)
- # cljs-dev (41)
- # cljsrn (4)
- # clojure (216)
- # clojure-android (1)
- # clojure-conj (6)
- # clojure-greece (1)
- # clojure-italy (11)
- # clojure-russia (127)
- # clojure-spec (63)
- # clojure-uk (34)
- # clojurescript (68)
- # core-async (5)
- # cursive (5)
- # data-science (1)
- # datomic (4)
- # dirac (11)
- # editors (7)
- # events (1)
- # graphql (12)
- # hoplon (39)
- # jobs (1)
- # liberator (3)
- # lumo (101)
- # off-topic (14)
- # om (3)
- # onyx (3)
- # parinfer (14)
- # re-frame (10)
- # reagent (2)
- # remote-jobs (1)
- # ring-swagger (17)
- # sql (21)
- # untangled (38)
- # vim (3)
- # yada (23)
Someone here posted few days ago a compilation of cljs code to js string, should have copied that snippet, but what am I missing
(cljs.compiler.api/compile-file (cljs.analyzer.api/empty-state) "(reduce + [0 1 2 3])" "" {:optimizations :none})
=> FileNotFoundException The file (reduce + [0 1 2 3]) does not exist.
Nevermind, scrolling up works https://clojurians.slack.com/files/nikki/F5RAAF813/screenshot_2017-06-09_01.57.56.png
I seem to recall that the google closure compiler assumes it compiles everything on a given page, making it impossible to have different .js files compiled by the closure compiler on the same page. But I can’t find a source for it, does anyone know if that assumption is correct?
@nha yes its not safe to have different files unless you use :output-wrapper
and :externs
or course
Just out of curiosity, do you know what happens if I have a compiled module already ( for instance like https://www.npmjs.com/package/transit-js (I know there is a .cljs version, this is just an example)). Can I use it as “plain” javascript and pass it through the cljs compiler again along other cljs/js code?
@nha in general your initial assumption is correct - separately compiled Closure generated JS is not a good idea
just to ask my dumb question of the day, there's no way to use advanced compilation to make a bundle per namespace (to be loaded asynchronously), correct? you can only bundle shared code across namespaces?
i have some hefty parts of my app that aren't frequently used and i'd prefer not to force people to download the whole thing if need be
@joshkh there is https://github.com/thheller/shadow-cljs/wiki/ClojureScript-for-the-browser#module-loader
I need still need to write a proper guide for all of it but the basics are there. it lets you async load stuff on demand
How do I get "bar" from #js {:foo "bar"} without doing js->clj? I thought .-foo would do it, but it doesn't.
I'm getting nil.
is https://github.com/clojure/core.incubator available for clojurescript somewhere? not seeing it, but this post http://blog.wjlr.org.uk/2015/01/17/fast-string-interpolation-cljs.html makes it sound like it should be :thinking_face:
Actually, no, but (.-foo-bar #js {:foo bar "foo bar"}) does yield nil.
Sorry if this off-topic, but what is the use-case of strint
? Why not just str
things together? Is it a performance issue?
Hah, munging converts (.-foo-bar #js {:foo-bar "foo bar"})
to this JavaScript: ({"foo-bar": "foo bar"}).foo_bar
So, is it possible to access it?
goog.object/get
Thanks
everything is ok right after page refresh, but after any hot-reload I get this warning (note clojure vs. cljs):
clojure.core/format
^--- Use of undeclared Var cljs.core/format
(it is in .cljc file)(:require
#?@(:cljs [[goog.string :as gstring]
[goog.string.format]]))) ;;<--- extra touch
;; then:
(gstring/format ...)
is there a macro or anything that allows me to write instead of this (fs.readFile "file" callback) that (??? (fs.readFile "file") callback)? and therefore would save me of all the troubles of callback hell?
@akond If I understand you correctly, this is more or less what core.async
is about. I haven't used it very much, but what I did do precisely alleviated my callback hell problems. Have you checked out any core.async
tutorials?
I haven't used manifold. I agree that core.async
has a strange API, but I think once you get over the initial learning curve it really pays off in the long run
i've seen what @tbaldridge has to say about core.async
some of those concerns are specifically about core.async on the jvm - it’s less complex in js
I think this couldn't be done unless, in addition to a macro for chaining the callbacks, the callbacks themselves were defined using some kind of defcallback
macro that hooked them into a callback manager behind the scenes