This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-01
Channels
- # beginners (117)
- # boot (8)
- # cider (22)
- # clara (3)
- # clojure (79)
- # clojure-italy (3)
- # clojure-spec (34)
- # clojure-uk (34)
- # clojurescript (74)
- # cursive (7)
- # datascript (5)
- # datomic (28)
- # defnpodcast (1)
- # dirac (9)
- # docker (25)
- # duct (1)
- # emacs (14)
- # fulcro (67)
- # graphql (1)
- # hoplon (15)
- # jobs (4)
- # juxt (6)
- # off-topic (76)
- # parinfer (3)
- # re-frame (25)
- # reagent (4)
- # rum (6)
- # shadow-cljs (1)
- # spacemacs (30)
- # sql (15)
- # unrepl (36)
- # yada (1)
I'm getting some strange behavior with cljs.
(gobj/get cljs-react-material-ui.reagent "app-bar")
(gobj/get cljs-react-material-ui.reagent "paper")
With these two statements, the first returns nil and the second returns the object I want. I aliased the ns to rui
and
rui/app-bar
rui/paper
both of these statements return the objects I want. When I console.dir
the namespace, app-bar
isn't in it, but I can still access itWhat could cause something like this to happen?
My suspicion is the google closure compiler. I have advanced compilation turned on
in the library, both objects are also defined the same way
Alright I found out in order to do dynamic access, I need to use app_bar
instead of app-bar
anybody know why?
(defn app-bar [...] ...) creates a thing called app_bar
see the munge
and demunge
functions
I discovered that when I started dumping vars to the console. I feel really stupid now because I totally knew js doesn't support kabab cased names
I just never put two and two together
+user=> (munge 'foo-bar!?!)
foo_bar_BANG__QMARK__BANG_
+user=> (clojure.main/demunge (str *1))
"foo-bar!?!"
Hey that's pretty handy
oh wait, those are the clojure versions, checking for cljs
:thumbsup:
with the cljs demunge it's in cljs.core (accessible normally in other words) and you don't need to convert symbol to string to round-trip
Thanks for the pointers. I'm pretty sure you answer like 4/5 of my questions. You deserve a cookie or something
haha no I'm trying to lose weight, thanks though
awhile ago i wrote a cljs wrapper for a cljsjs library. it took some react components and made clojurescript looking functions that generated those componenets
i am curious, would the closure compiler be smart enough to strip away the vars I don’t use in my application?
does the testing
macro works for async
tests? it does not seem so
probably I have positioned it wrong
it should work as long as the testing form does not exit until the async operation does
(and the wrapping deftest naturally)
iirc the right way to do this is (deftest foo-test (testing "some thing about foo" (async ...))
yep I also found I needed an additional take!
https://stackoverflow.com/a/30781278
thanks for answering!
having worked with mocha
for a while, I gave that as a given 😄
If you’re trying to support lots of browsers and versions, you may want to consider using the FileSaver.js library, which has a recent enough version in cljsjs
This is a snippet from my personal application.
You can do like send-pdf-to-browser
if you want to download file with cljs.
@timok You can do like this.
(def debug? ^boolean js/goog.DEBUG)
(def endpoint (if debug? "localhost:3000" ""))
replied in beginners
Hi everyone!
I have a problem with Closure Compiler externs.
I use pouchdb
alongside with socket-pouch
and pouchdb-authentication
and it's obvious that I get an error with :advanced
optimizations flag. As far as I know, I need externs to solve the problem. So how should I do it?
Both pouchdb
and pouchdb-authentication
are present in cljsjs, but there's no socket-pouch
available there
See https://clojurescript.org/guides/externs for autogenerating them. It is also easy to write by hand if you only use a small part of the api
@melvoloskov You can generate missing externs here http://www.dotnetwise.com/code/externs/
U put them in the root dir of your project or on the classpath and in the :compiler section of cljsbuild config refer to them
Also see https://lispcast.com/clojurescript-externs/ for an explanation
Wow, thanks!
yep. I declared libraries as their own externs and disabled extern validation as mentioned at purelyfunctional tv, and it worked just neat
hi, how can I appende to a re-com component the :component-did-update
logic for example?
hi @tomaas, you just pass a map to reagent/create-class
with react lifecycle methods as functions
(defn my-component []
(reagent/create-class
{:reagent-render (fn [args]
[:div args)
:component-did-update (fn [props] (prn "component did update!"))}))
I may wrap the re-com component with (r/create-class..) but if in the render function I dont deref the atom I pass to a re-com's component this does not work
Haven't used it but I suppose as usually with such frameworks re-com
functions return only hiccup forms, so the render
method.
How often do you add more than one build to the :cljsbuild :builds in the project.clj
Hi. Always 🙂
When I have Clojure + Clojurescript project, I have build for dev, test and prod (different in optimization level and with possible additional dependencies for e.g. test).
When I have CojureScript at both frontend and backend, then I have 6 builds instead of 3 🙂.
You can see example template for Macchiato, where there is dev
build for backend: https://github.com/macchiato-framework/macchiato-template/blob/master/resources/leiningen/new/macchiato/project.clj#L52 and dev
build for frontend: https://github.com/macchiato-framework/macchiato-template/blob/master/resources/leiningen/new/macchiato/project.clj#L32 (each within their own profile)
Ok, I'm editing CIDER to be able to detect what REPL you would want during dev, so in this case I would look for :builds :dev :compiler :target and see that you want to use nodjs and automatically suggest to change the REPL backend to node
I’m writting something that tries to detect if someone is targeting a particular platform and I realized it only works if there is one element in the :builds array
in case of cljsbuild always. since you'll need one build for development and one for optimized release builds.
Sorry to put the burden of effort onto you but could you post an example project.clj that includes these two builds?