This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-29
Channels
- # aleph (2)
- # architecture (1)
- # beginners (5)
- # boot (7)
- # cider (24)
- # clara (28)
- # cljs-dev (7)
- # cljsjs (3)
- # cljsrn (24)
- # clojure (145)
- # clojure-italy (2)
- # clojure-nl (7)
- # clojure-uk (54)
- # clojurescript (159)
- # cursive (49)
- # data-science (8)
- # datomic (23)
- # editors (10)
- # emacs (2)
- # fulcro (123)
- # graphql (12)
- # hoplon (2)
- # java (23)
- # jobs (1)
- # jobs-discuss (2)
- # leiningen (17)
- # mount (5)
- # nrepl (5)
- # off-topic (20)
- # om (2)
- # onyx (25)
- # parinfer (2)
- # pedestal (1)
- # re-frame (8)
- # reagent (7)
- # ring-swagger (1)
- # shadow-cljs (24)
- # spacemacs (7)
- # specter (6)
- # tools-deps (7)
- # vim (2)
Can someone sorta explain how the cljs browser repl works with regards to eval'd values and re-compilation? It's kind of magic how I can declare an atom, and then reset!
the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it.
Is there a way to persist that value in the repl so that it survives a re-compilation?
also is it possible to declare 'global' functions that are available at the repl no matter which namespace is currently selected?
you can make a value survive recompilation by using defonce
instead of def
. that’s what you’ll want to with your application state
i’m not sure what you mean by
>then reset!
the value when the code path is executed by me in the browser and deref that value in the repl to mess around with it.
doing stuff like that, where I want to mess around with a value so I'll reset it in an atom. 'exercise' the code in the browser, come back and the atom will have the value
maybe the piece you are missing is that when you drop into the cljs repl (by calling (shadow/nrepl-select :app)
you are actually running code on the browser
whatever code your run in the cljs repl is just like running javascript in the browser console, except that it gets compiled to js first
yea the fact that I can write arbitrary code, eval it in the repl, and it gets compiled on the fly down to javascript and eval'd in the correct place is pretty wild
is there a way to declare values in the repl that are "above" or global to all namespaces?
that’s why the cljs repl is often totally effed up and hard to get going. you have a menage a trois of the browser, your editor / tty, and cljs compiler (which is running in java)