This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-03
Channels
- # beginners (98)
- # boot (18)
- # chestnut (2)
- # cider (90)
- # cljdoc (3)
- # cljs-dev (1)
- # clojure (64)
- # clojure-dev (14)
- # clojure-dusseldorf (4)
- # clojure-italy (11)
- # clojure-nl (5)
- # clojure-spec (9)
- # clojure-uk (69)
- # clojurescript (63)
- # code-reviews (2)
- # core-logic (20)
- # cursive (13)
- # datomic (52)
- # dirac (2)
- # emacs (4)
- # figwheel (6)
- # hyperfiddle (13)
- # luminus (4)
- # nrepl (1)
- # off-topic (7)
- # onyx (9)
- # overtone (3)
- # parinfer (3)
- # pedestal (1)
- # re-frame (31)
- # reagent (74)
- # reitit (34)
- # rum (3)
- # shadow-cljs (51)
- # spacemacs (22)
- # specter (7)
- # tools-deps (23)
- # uncomplicate (3)
- # vim (9)
Can
be used in a cljsbuid + figwheel project?
I guess not given
but also I'd be surprised a whole language feature simply isn't supported
How do I unwrap optionally quoted EDN literals as user input in ClojureScript using read-string? E.g. (cljs.reader/read-string "'[1 2 3]")
returns '
and not (quote [1 2 3])
as I would expect, but I'm interested in [1 2 3]
. The user can also input "[1 2 3]" and I want the same output. Do I need to parse result and look for the presence of the quote
symbol?
I made a Cljs tool that translates boot-clj and Leiningen :dependencies
to the newer deps.edn
format: https://theronic.github.io/depsy/ (source on GitHub)
@U04V70XH6 thx for boot-tools-deps š
Hello, Iām trying to use js*
with a composed string as argument but I got Invalid js* form
error. Iām not sure if what Iām doing is possible.. This works (js* "require('nano')(url:'
but this one not (js* (str "require('nano')" "(url:'
. Of course I want to get the IP part from a configuration file, so as a variable. Thanks
@paolo.galizzi whats the point of using js*
? just do (let [nano (js/require "nano")] (nano #js {:url the-ip}))
or better yet (ns ... (:require ["nano" :as nano])) (def the-thing (nano #js {:url ...}))
Mmm good pointā¦there isnāt a really reason why I was using js*
.. Iāll try as you suggest..thanks!
Relating this to closurescript-beginners; is there a faq that covers all aspects of initializing a CLJS project, covering shadow, cursive, cider, lein, clj-tools, boot and god knows what else there is?
Or perhaps just a list of repositories where each entry is sanctioned by the respective author of above mentioned, I donāt know what to call it, complecting element in the CLJS universe? ;-)
Personally Iād like a map of the current landscape and how/where the pieces have an effect in the process of developing
@schpaencoder: I haven't seen anything like this. I've followed this which is a good intro to shadow-cljs: https://www.jacekschae.com/learn-reagent-free?coupon=SHADOW. purelyfunctional courses by Eric are awesome. But such resources are few and far between. Frankly, my experience is that clj/cljs is not newb friendly. cljs more so. The only exception I found so far is re-frame which has great documentation. There seems to be no one-place where all aspects of a non-trivial cljs (with clj) project are discussed. It feels like clj/cljs stuff is done by very smart people who don't have time to do handholding. clj/cljs entry skill level requirement is very very high.
For me, luminus has been the only thing that let me actually do something in clojure without making me go completely insane
@dumrat great course, I learned a new thing too, how you have to tell shadow what nrepl to use, and that I have to revisit atom, because yum those in-line error messages
I would like to think that everything in Clojure-land is composable, however, only the toolmakers know how
I believe Eric Normand: https://youtu.be/VPp0ahoQR3o
Suddenly I remembered why I ditched atom. Using 300% of my cpu while idle.
hi all, not sure if it's the right place to ask re-frame question but I will give it a go. Do you know if its possible to trigger multiple events in re-frame, from an event handler? The :dispatch keyword takes a vector with only one event as far as I know. Is this even an acceptable pattern?
@nustiudinastea: You can use dispatch-n
. As far as I remember, it goes like this:
(reg-event-fx
::my-event
[_ _]
{:dispatch-n [[::event-1 args]
[::event-2 args]]})
ohh snap, didn't know about :dispatch-n. Will look it up, thanks so much!
@dumrat dispatch-n works beautifully. Thanks for the tip
they are intentionelly not supported in shadow-cljs in .cljs
source files. if you just want to use tagged literals in EDN thats fine and works via cljs.reader/register-tag-parser!
> they are intentionelly not supported @thheller interesting! what's the reasoning behind?
caching nightmares. its basically impossible to have reliable caching with those in place.
better to just require a ns and use (that-ns/foo ....)
than rely on some compiler magic and use #that-ns/foo ...
@mfikes made a good point about their use in the REPL though. so I will probably enable them there
> better to just require a ns
my use case was to create a #bigdec
, which could resolve to the implementation du jour (transit, big.js) as they are always subject to change
of course one could create a fn for that (Adapter pattern), but seems overly verbose for such a basic notion (big decimals)
I think its unlikely that you'd actually be able to swap the entire implementation by just switching the reader literal
I noticed a function defined as so:
(defn funny-looking ( . . . ))
This is the first time I see a function defined without an argument list. I know its not a type-o because the app is working as intended. But what is the difference from a normal function defined as
(defn serious-looking [] ( . . . ))
?
@mario.cordova.862 probably looking at a multi-arity fn? (defn foo ([] ...) ([a] ...))
?
Yeah @vemv, I felt that the ability to have ratio value literals could be useful: https://github.com/mfikes/precise
From what I see so far, I donāt know that you can effectively use resolve
calls during macroexpansion-time when using macros in CLJS - I may be wrong, so seeing if anyone can shed some light on the situation.
Consider this:
foo/mac.clj
(ns foo.mac)
(def a "hello")
(defmacro foo [] [(resolve 'a)])
(ns foo.bar (:require-macros [foo.mac :as f]))
(enable-console-print!)
(println (f/foo))
I get something like [nil]
.Trying to track through the CLJS compiler and analyzer to see what is going on during macroexpansion, and I belive it is due to *ns*
being boudn to cljs.user
during resolve
being called at macroexpansion time
In particular, when I get about as deep as cljs.compiler/emit-source
, there is a direct binding to ana/*cljs-ns* 'cljs.user
This is then used in cljs.analyzer/macroexpand-1*
via binding [*ns* (create-ns *cljs-ns*)]
resulting in the *ns*
being bound to cljs.user
when the macro fn is called.
since cljs.compiler/emit-source
doesnāt appear to yield to any passed down ācompile envā to bind ana/*cljs-ns*
to, I think there isnāt a effectively way to instead bind ana/*cljs-ns*
to the CLJ namespace that the macro was written in.
This may be a known limitation. Itād be good to hear more about it though. I couldnāt find anything related on this topic doing searches.
@mikerod *ns*
is always bound to the current namespace, not where the macro was written
I donāt know that thereās a good way to do what youāre talking about even in Clojure
@dnolen ah yeah, I guess I tried to get too fancy in my example, but consider trying to resolve something from clojure.core
- that also doesnāt work in CLJS
and in Clojure it would, but I think I can accept the general idea though that doing macroexpansion time resolve
(or similar) can be risky
I think it should just be fully-qualifying the symbols and maybe thatād be it. so (resolve 'foo.mac/a)
instead
@dnolen You are referring to using cljs.analyzer.api/resolve
like in cljs.spec.alpha/exercise-fn
?
The Graal.JS REPL has landed on ClojureScript master.
{:deps {org.clojure/clojurescript {:git/url ""
:sha "04e6bd9073daa905543d7decab95a2252c2e53e2"}}}
then
$ clj -m cljs.main -re graaljs -r
Cloning:
Checking out: at 04e6bd9073daa905543d7decab95a2252c2e53e2
cljs.user=> (.eval js/Polyglot "R" "sum(1:100)")
5050
cljs.user=> (.eval js/Polyglot "ruby" "(1..100).reduce(:+)")
5050
You need to have Graal Java in path for this
$ java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
GraalVM 1.0.0-rc4 (build 25.71-b01-internal-jvmci-0.45, mixed mode)