This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-12
Channels
- # arachne (1)
- # beginners (26)
- # cljs-dev (53)
- # cljsrn (1)
- # clojure (140)
- # clojure-italy (13)
- # clojure-russia (14)
- # clojure-spec (5)
- # clojure-uk (6)
- # clojurescript (52)
- # datascript (4)
- # datomic (11)
- # dirac (11)
- # emacs (12)
- # hoplon (9)
- # jobs (4)
- # lein-figwheel (1)
- # off-topic (29)
- # om (10)
- # om-next (1)
- # pedestal (3)
- # protorepl (1)
- # re-frame (16)
- # ring (12)
- # rum (27)
- # slack-help (12)
- # spacemacs (27)
- # unrepl (19)
- # untangled (26)
- # yada (8)
@dominicm @darwin there may well be bugs with new
's code emission, as we only started allowing stuff like you're doing recently
previously the argument to new
was enforced to be a symbol
it looks like they may be more about mutating shared state rather than functionally wrapping the test?
it should be passed a function according to this… https://github.com/clojure/clojurescript/blob/2f8a1529955acc943ac8082ab5848b2cba54bc4d/src/main/cljs/cljs/test.cljs#L571
oh wow… it's because there's an undocumented option of not using {:before … :after …}
. instead you just (use-fixtures :once foo-fixture)
what are common ways for handling configuration and clojurescript ? i was only able to find surprisingly little about this topic what i’m talking about is some way to define some configuration variables at compile-time, so when the clojurescript code is generated. this will allow me to, say, differentiate between dev and production builds.
or does https://github.com/adzerk-oss/env properly address my use case ?
https://www.reddit.com/r/Clojure/comments/55zbps/configuration_library_for_clojurescript/d8f0j52/ is what i found on reddit
i’m looking at http://cljs.github.io/api/cljs.core/goog-define now
Macros are nice if you need to share some config between server side and client side. But the goog-define is often enough
goog-define
has the bonus effect that it is fully compatible with closure :advanced
dead code removal
@lmergen I personally try to stay away from goog-defines and use :external-config
with macros instead, had a bad experience with goog-defines preventing proper DCE in :advanced
compilation without careful type hints[1] and got burned by a change in ClojureScript compiler behaviour once[2]
[1] https://github.com/binaryage/cljs-devtools/releases/tag/v0.5.3
[2] https://github.com/binaryage/cljs-devtools/commit/4e368408986bf739b56aad64e064b854fd7989d2
here is an example how to get :external-config
from compiler options via a macro:
https://github.com/binaryage/cljs-devtools/blob/0c773ba0539639bf7e3c164cd0e30b3696f7e110/src/lib/devtools/prefs.clj#L12
here I emit it into cljs as edn:
https://github.com/binaryage/cljs-devtools/blob/0c773ba0539639bf7e3c164cd0e30b3696f7e110/src/lib/devtools/prefs.clj#L16
and here I use it:
https://github.com/binaryage/cljs-devtools/blob/0c773ba0539639bf7e3c164cd0e30b3696f7e110/src/lib/devtools/prefs.cljs#L22
here is an example of :external-config
in lein’s project.clj:
https://github.com/binaryage/cljs-devtools/blob/0c773ba0539639bf7e3c164cd0e30b3696f7e110/project.clj#L69
@darwin thanks, that looks good as well! i’ll keep it in mind for later, though, since my use case is pretty simple (i’m using cljs only for end-to-end tests for now)
I need to initialise an app with a channel that "doesn't do anything". My first reaction was (chan (dropping-buffer 0))
, but that doesn't work because there's an assertion deep in the library that disallows buffers of size 0
has anyone a good recommendation on learning how to embed a js-library in my clojurescript webapp?
@timok I'd start by checking if the library is included in http://cljsjs.github.io/
(After I have checked that the functionality I'm looking for is not already in the Google closure library)
If those fail you can read up on externs https://github.com/cljsjs/packages/wiki/Creating-Externs https://gist.github.com/swannodette/4fc9ccc13f62c66456daf19c47692799
anyone ran into TypeError: undefined is not an object (evaluating ‘ReactInternals.ReactComponentTreeHook’)
` when upgrading to reagent 0.6.1?
@credmp nope works for me with 1.9.495, what CLJS version are you using ?
@sineer you could always use javascript-based libraries, like three.js. Depends on how many features you need right away
@sineer check out http://cljsjs.github.io for externs to those libraries, including three.js.
@timok We have some libraries that are included just by the means of a <script>
tag in the index.html
. The good thing is that it works, just by using js interop. Ie. js/SomeLibrary.foo()
The bad parts on the top of my head are 1) we cannot use advanced compilation (which isn’t about performance but more about size afaik). 2) our unit tests running through phantomjs do not have access to the library, so if they require
any namespaces that use the library, they’ll fail.
In a cljs-repl (eg figwheel’s), is it possible to override how certain types are output? Eg displaying a function as just (fn […])
?
@grav you can specify your own :print
function when configuring this repl call:
https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/repl.cljc#L953
with figwheel you should be able to configure it via :repl-opts
(not tested):
https://github.com/bhauman/lein-figwheel/blob/250dcb6911d402609fe283afb3b98e081d068c3c/sidecar/src/figwheel_sidecar/repl.clj#L186
any ideas on how to get clj->js
to give me a JS key that is a string that starts with a colon? like : (clj->js {":hover" {:background "red"}})
i'd want this JS output: {":hover": {"background": "red"}}
@danvingo oh ok, but you can by doing:
(defn keyword->str [k]
(str (if-let [n (namespace k)] (str n "/")) (name k)))
(extend-type Keyword
IEncodeJS
(-clj->js [x] (keyword->str x))
(-key->js [x] (keyword->str x)))
with of course you custom encoding/decoding
thanks D.Nolen for thinking ahead 😄
(or the contributor it was someone else's work)
pondering if this can be (ab)used to get macro like behavior for types that expand to JS forms
oh I bet that have been abused a lot ... 😄