This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-24
Channels
- # announcements (4)
- # beginners (37)
- # boot (13)
- # boot-dev (3)
- # calva (122)
- # cider (16)
- # clara (13)
- # cljs-dev (3)
- # cljsrn (8)
- # clojure (311)
- # clojure-denver (1)
- # clojure-dev (14)
- # clojure-europe (7)
- # clojure-italy (36)
- # clojure-nl (3)
- # clojure-spec (11)
- # clojure-uk (77)
- # clojurescript (91)
- # core-async (10)
- # cursive (9)
- # data-science (5)
- # datomic (46)
- # devcards (2)
- # emacs (6)
- # figwheel-main (15)
- # fulcro (51)
- # jobs (3)
- # kaocha (10)
- # nrepl (6)
- # off-topic (53)
- # om (1)
- # onyx (2)
- # pathom (5)
- # reagent (50)
- # reitit (26)
- # shadow-cljs (153)
- # spacemacs (17)
- # specter (5)
- # speculative (1)
- # test-check (19)
- # tools-deps (15)
- # yada (3)
is anyone use re-natal with https://github.com/wix/react-native-navigation?
Is there a way to require a module outside ns macro?
You could try this hack. I don't remember if I tested in advanced compile mode. It'd be interesting to find out. Parameterizing requires using clojure-defines https://clojurians-log.clojureverse.org/clojure/2018-08-08/1533739640.000300 And another example of conditional requires based on what's available in the cljs.analyzer/constant-table: https://clojurians-log.clojureverse.org/cljs-dev/2019-01-08/1546981037.172600
But specifically, those hacks are parameterizing the ns declaration, not calling require outside of the ns declaration
(require '[your.namespace :as yn])
yeah but it works only in dev, it won’t compile for production
so you can’t do conditional require for example
unless using a macro
so if i wrap it in macro
then it will just work perfectly fine
is that so?
ooooh, wait no, I’m wrong, it won’t work anyway 😄
conditional require is not possible due to how the closure compiler works. if you want to include dev only stuff use :preloads
basically require
on itself is a dynamic import in cljs which works only in dev (unless you ship the whole compiler into a browser and implement IO layer to make require work) and require in ns
form is a static import
@thheller Hello 🙂 Thanks a lot for your work with shadow-cljs. I wanted to know if there exists a way to define dependencies depending of your build key? For the context, re-frame-debux require two different version depending on the optimization profile (one for dev and one for release)
hey guys, has anyone experience problems with js->clj
on Javascript class instances ? I tried to use it on the Request/Response object from fetch
api but it couldnt convert the object. My guess is that it is because the constructor is not js/Object but something else 😕
do you mean actual Response
instance?
why not read response body and then apply js->clj
?
because the body doesnt contain the http status
, and all other header stuff that I would like to check
@carocad js->clj
is only really meant for JSON-ish data. it can't properly convert class instances unless you tell it how by implementing the IEncodeClojure
protocol for those classes
(defprotocol IEncodeClojure
(-js->clj [x options] "Transforms JavaScript values to Clojure"))
> js->clj
is only really meant for JSON-ish data
hey @thheller , the thing is that those objects are “json-ish”. The hack that I used to solve that was to do (js/JSON.parse (js/JSON.stringify object))
. Which does the job but feels wrong as hell.
that is indeed hacky as hell. doesn't make the data any more json-ish though. 5 lines of code that extract the properties you want will definitely make that faster and less error prone
> doesn’t make the data any more json-ish though
fair enough. Is there any way to know in advance is an object is json-ish ? So far my understanding was that js->clj
would traverse an object the same way that js/JSON.stringify
does
hey everyone, is there some way to view the available fields/methods of a js object in the cljs repl?
i can't get a repl (or the debug mode) working in firefox, so i want to explore the objects i'm receiving in my cider cljs repl, but i have no idea how to interact with something like #object[SyntheticEvent [object Object]]
hmm, maybe cider isn't perfect for cljs (or the js interop part of it), but i get no autocompletion for goog.object, although the import seems to be successful
seems i have to google stuff anyway 😓 simply calling (goog.object/getAllPropertyNames some-event)
works, of course
@timo.freiberg also sometimes it's simpler to console.log
the thing and inspect in the browser
this is true even for ClojureScript values if you're using Chrome due to cljs-devtools
ah true, i forgot that the value inspection feature works with values printed to the console as well as in debug mode
very nice
REBL is probably an even better answer in the long run but I think you'll encounter sharp edges at this time
i suspect console.log
will suffice for now, thanks a lot for the help!
There was no explicit mention but Stuart said "I can't wait to see what the ClojureScript people do with this". Read that as you will. :thinking_face:
btw. at some point I’d like to support REBL-like traversing of datafy-ed structures in cljs-devtools (similar to how meta data are offered today), just waiting for this to get some tangible use-cases

@manu usually split up the thing in request
and response
. Then response
usually just calls some other functions that does the parsing/formatting of the data to the right format, and request
ends up hitting some endpoint that I start when running the tests, but that's it
@victorbjelkholm429 I would like to simulate the fetch response (so obtain a promise) and handle this promise..
Can someone point me to a barebone example of figwheel-main project that has no browser at all, just nodejs? Honestly - I do understand now when newcomers complain - it can be truly, utterly confusing to start a Clojurescript project from scratch. And I’m not new to Clojure.
Honestly I’m not trying to complain for the sake of it. I’m just trying to be emphatic for people who would like to try something without having to dig through ton of docs.
Landscape of Clojurescript right now could be so confusing for a newcomer. We have lein, we have boot, we have figwheel-lein, figwheel-main, shadow-cljs… And none of them feel like “idiomatic” way of doing things.
I agree. I’d call figwheel-main the idiomatic way of doing things. But you are correct that there has been no written blessing.
sigh… I think we just don’t have enough people willing to contribute to the docs. Somehow I think we (Clojurists in general) tend not to care about documentation much
a simple example of how to compile a nodejs project without reloading, just using CLJS:
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}' -m cljs.main -t node -c your.main-namespace
or to get a REPL:
clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "RELEASE"}}' -m cljs.main -re node
and then you can reload your namespace after making changes, like:
(require '[your.namespace] :reload)
This should already get you going.No, that easy I get it… but once you want to add “reloading” to that… it suddenly becomes a bit more complicated
those things don't have an integration with editors. not sure how that's a realistic thing to try to use in anger
for testing code in Node I mean. No, I just open a REPL in a terminal. Edit text in Emacs. Then call :reload in the REPL
ah yeah. i can't imagine 8 hours of development without navigation, completion, and doc
guys… guys… I just need the barebones minimal example of figwheel-main on nodejs. For demonstration purposes. What do I need? - deps.edn file
{:deps {org.clojure/clojure {:mvn/version "1.9.0"}
org.clojure/clojurescript {:mvn/version "1.10.339"}
com.bhauman/figwheel-main {:mvn/version "0.2.1-SNAPSHOT"}}
right?
so now if I do: clj -m figwheel.main
- that thing opens a browser and connects repl to it. I do not need browser@bhauman Node output being logged to: target/node/dev/node.log
how do you change it to go directly to the repl/nrepl buffer?
meh… no matter how hard you try - you won’t deter me from using figwheel-main. It’s so fucking awesome
You could maybe canabalize this and print file updates to the repl in a macro https://github.com/stuartsierra/lazytest/blob/master/modules/lazytest/src/main/clojure/lazytest/watch.clj
so webcomponenets in cljs. the last library that seemed to deal with them was archived 3 years ago. Only within the last couple months has the webcomponent standard been implemented on all greenfield browsers (not counting edge since its going soon anyway) Am I missing something about why theres not much ecosystem support for this kind of thing? is it all just really easy to implement with regular interop? do web components suck? has just no one gotten around to building a library for it?
my interest in them is essentially page composition https://micro-frontends.org/#page-composition as described by the micro frontends folks
basically, different teams build different products that are exposed via a web ui that can be embedded in other web uis to create a larger, integrated web product
hmmm. I suppose, if you could define webcomponents in cljs, and then just drop their element names in your hiccup forms, it'd probably work.
> Each team builds their component using their web technology of choice and wraps it inside a Custom Element (e.g. <order-minicart></order-minicart>).
definitely don't want to include 15 different tech stacks in your page since it will be gigantic
rather settle on one and use it everywhere for which the CLJS community pretty much adopted React
I mean, that hardly seems like a reasonable objection for a strategy of decoupling services
if page load time is a problem, then you can establish conventions for which technologies are to be included in the composed page
personally, I see all the webcomponents in our stack being react based, but there are legacy structures which are not currently react based, and I'd like to be able to replace it one vertical at a time
All I know is, they put many years of effort into that standard... Hopefully it's good for something
I think they advertise it as "like react components but now built into the web" so maybe they're shipping with some extra efficiencies built into the engines and browser code-bases