This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-08-19
Channels
- # beginners (59)
- # calva (20)
- # cider (25)
- # clj-kondo (12)
- # cljdoc (3)
- # cljsrn (15)
- # clojure (104)
- # clojure-europe (4)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-spec (14)
- # clojure-uk (13)
- # clojurescript (33)
- # code-reviews (26)
- # core-async (1)
- # cursive (5)
- # data-science (3)
- # datomic (8)
- # emacs (3)
- # fulcro (5)
- # graphql (3)
- # hoplon (1)
- # jobs-discuss (4)
- # kaocha (14)
- # nyc (1)
- # off-topic (33)
- # pathom (4)
- # pedestal (2)
- # quil (1)
- # re-frame (5)
- # reagent (10)
- # reitit (6)
- # rewrite-clj (3)
- # shadow-cljs (173)
- # specter (7)
- # sql (4)
- # vim (58)
- # yada (3)
I am using re-frame and lein figwheel. When I want to test some subscriptions or events from the repl, I need to require the re-frame namespace: dev:cljs.user=> (require '[re-frame.core :as rf]) dev:cljs.user=> (rf/subscribe [:posti-kioski-gui.sending/prices]) .... How can I perform the (require '[re-frame.core :as rf]) initialisation every time I run "lein figwheel" automatically?
@robert783 put user.cljs
with that code on the classpath and it will be executed when build starts
Thank you! I added a new file src / cljs / user.cljs (I am not sure if this is equivalent of "on the classpath). As content of the file, I have:
(ns user)
(println "Hello from user.cljs")
(require '[re-frame.core :as rf])
(require '[cljs.pprint :refer [pprint]])
This is partly successful since the message from println is printed. However, (rf/subscribe [:aaa]) gives error in"rf is not defined"also put user.cljs
under dev
dir and add the directory to source paths for dev build, so you don’t include that into prod build
Now user.cljs is at src_dev/cljs/user.cljs
and I have added src_dev/cljs
as source-path in :cljsbuild
. Println gets executed there ok. The remaining problem is that any require-statements I execute in user.cljs do not seem to have effect on bringing those namespaces visible in the repl
@robert783 move the require
calls into the ns
form like normal via :require
I have now in user.cljs
(ns user
(:require [re-frame.core :as rf]))
(println "Hello from user.cljs")
Still I get error "rf is not defined" when I write in the repl
dev:cljs.user=> (rf/dispatch [:aaa])
Thanks, now works! 🙂 So in user.cljs I have now
(ns cljs.user
(:require [re-frame.core :as rf]))
For some reason my IDE (idea + cursive) still gives me error about "Namespace name does not corrspond to filesystem hierarchy" (although the code works). Based on the namespace cljs.user, Cursive would like now to move user.cljs to src_dev/cljs/cljs/user.cljs
(since I have src_dev/cljs
as source path. If I move user.cljs there, Cursive is satisfied but the code is not loaded any more at startup. I can live with this Cursive error.
@robert783 Perhaps you can make Cursive not complain by writing the code as
(require '[re-frame.core :as rf])
(The default namespace for that file is cljs.user
.)Someone somewhere mentioned that a compile-to-wasm language with Clojure-like syntax might be a good thing for a subset of Clojure’s features, and without GC (as far as I remember). Is there a discussion going on about this anywhere?
lisp without a GC is such a weird thing for me considering lisp was the first language to have a gc
@grav not that I'm aware of but it's likely I might work a bit on that in the near future as it would be best if the results could be easily integrated with the ClojureScript compiler
but GC in WASM is not off the table either - there's a ton of design work to do before trying anything
how can I print the js code of a function, like it used to work in the CLJS repls of olden days?
I tried that, but I'm getting:
cljs.user=> (set! *print-fn-bodies* true)
true
cljs.user=> f
#object[cljs.core.MetaFn]
Following up on @robert783’s question earlier and thinking about it a bit, is it the case that although the default ns for CLJS is cljs.user
the compiler expects that file to be in user.clj
? If so, I’ll need to add an exception to that error check.