This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-12
Channels
- # beginners (40)
- # boot (2)
- # cider (16)
- # clara (2)
- # cljs-experience (2)
- # clojure (100)
- # clojure-italy (11)
- # clojure-russia (2)
- # clojure-spec (9)
- # clojure-uk (34)
- # clojurescript (36)
- # community-development (3)
- # core-async (4)
- # cursive (4)
- # datascript (1)
- # datomic (20)
- # duct (10)
- # emacs (1)
- # fulcro (2)
- # off-topic (40)
- # onyx (12)
- # overtone (8)
- # portkey (6)
- # quil (1)
- # re-frame (7)
- # ring-swagger (2)
- # shadow-cljs (2)
- # spacemacs (2)
- # test200 (10)
- # tools-deps (16)
- # unrepl (1)
- # vim (24)
I'm curious on whether ES6 Modules will simplify how clojurescript will handle modules in the future. It seems to have it's own system of handling CommonJS modules and similar modules
What is the conventional way to export clojurescript code as a node.js module? That works with require()
is there a way to get the current route using secretary to set an active
class on a link?
@dominicm I do not think core provides something more than ^:export
, I might be wrong though
So you can expose symbols that become JS vars, what is your use case?
@richiardiandrea I found a blog post saying I needed to write some "shim" javascript to re-flatten things out. I've ended up with:
var clj_refactor = require('./compiled.js')
module.exports = clj_refactor.clj_refactor.main._main
@dominicm yes that is what I do in my lamdbas as well. In comparison, shadow-cljs has more options regarding JS consumption, one explicitly for node library.
I'm using a clojurescript library that i need to modify. Is there a good way of doing this? like can i fork the repo and point the project.clj dependency somehow at a local folder while i fix the issues?
or using deps.edn: https://clojure.org/guides/deps_and_cli#_using_local_libraries
With shadow-cljs you can shadow single files locally that will override anything from a jar. https://shadow-cljs.github.io/docs/UsersGuide.html#_hacking
you can do that with lein’s checkout dependencies: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
hi all, is default-destructuring supported on namespaced keywords?
(let [{:keys [foo/bar] :or {foo/bar 2}} something])
With shadow-cljs you can shadow single files locally that will override anything from a jar. https://shadow-cljs.github.io/docs/UsersGuide.html#_hacking
@levitanong (let [{:keys [foo/bar] :or {bar 2}} something])
@mfikes whoa, i didn’t know the latter was even possible. The former didn’t seem to work for me.
@levitanong So, for example (let [{:keys [foo/bar] :or {bar 2}} {:foo/bar 42}] bar)
doesn't evaluate to 42
for you?
i just realized something… if the object being destructured is {:foo/bar nil}
, then it shouldn’t be 2, because the value was explicitly stated to be nil
@mfikes so if the latter is a thing, then does that mean that, given:
(def thing {:foo/bar 2 :baz/rutten 3})
(let [{:foo/keys [bar] :baz/keys [rutten]} thing])
;; bar = 2
;; rutten = 3
holy moly, that is so cool!
anyway, thanks for your help @mfikes!
are there any debugging / logging libraries out there that deal with javascript objects and clojurescript datastructures with equal ease?
i’m so tired of getting [Object object] or whatever as output when i’m confused about the type of the variables i’m trying to debug
js/console.log
with cljs-devtools has no problems with either
right that’s a good point. i sure would like a pretty printer though. it is much easier than drilling down
the other thing with that approach is that it only works if you pass the object unchanged to console.log so when used with spy macros and other types of logging conveniences (like using color output in the console) it is hard to get that to work right
to see [Object object]
someone must be calling toString
on your javascript objects, probably calling str
on them
I think if your logging library was written properly it would serialise javascript objects via pr-str
which goes through pr-writer
machinery which tries to drill into #js objects and print them as cljs maps, here is a proof:
https://github.com/clojure/clojurescript/blob/78753d376d5bfe9afd1dbb98eea15fd5bd312255/src/main/cljs/cljs/core.cljs#L9936-L9943
yes that’s exactly what’s happening because I’m trying to get fully expanded logging in certain circumstances. sometimes with deeply nested structures, it is simply nicer to have it expanded out so I don’t have to drill down with the mouse
i’ve also been trying to experiment with the color output features of chrome, because it can be really handy to selectively print stuff in red so that i can find it quickly. but to do that, you have to get to a string representation
Hi all. I'm trying to interop with a JS lib, and have had to write a really basic externs file and an accompanying foreign lib:
var SlateAutoReplace = {
"AutoReplace": function() {}
};
When I require the lib and try to use the loaded JS, the AutoReplace
fn exists as a default
attribute in the SlateAutoReplace
module object. In order to call the fn I have to do:
(.default js/SlateAutoReplace args...)
But the following fails:
(js/SlateAutoReplace.AutoReplace args...)