This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-18
Channels
- # beginners (123)
- # boot (3)
- # cider (6)
- # clara (1)
- # cljs-dev (139)
- # cljsrn (9)
- # clojure (59)
- # clojure-italy (5)
- # clojure-uk (41)
- # clojured (10)
- # clojurescript (67)
- # community-development (1)
- # component (2)
- # core-async (7)
- # cursive (4)
- # datomic (4)
- # defnpodcast (2)
- # fulcro (23)
- # graphql (1)
- # jobs (2)
- # leiningen (4)
- # off-topic (32)
- # portkey (7)
- # protorepl (5)
- # re-frame (19)
- # reagent (5)
- # reitit (23)
- # shadow-cljs (29)
- # slack-help (1)
- # spacemacs (1)
- # tools-deps (21)
- # unrepl (18)
hey @danielstockton @devicesfor @lee.justin.m I wrote up my thoughts for your consideration here: https://medium.com/@lwhorton/why-clojure-script-e4a69cc5168a
Thanks @U0W0JDY4C. I’ll be sure to take a look tomorrow.
This is a nice post, but I feel that some items, like "Lastly, the Clojurescript developer experience in terms of ergonomics, speed to delivery, extensibility, and bug-to-feature ratio is phenomenal" are not exactly valid. When working with large CLJS applications, setting up a workflow comparable to one in JS is not where I would expect it to be. I honestly found setting this up was considerably more challenging than webpack. I feel what I am trying to say is we say these things, but when people come to the language, they are consistently slapped in the face by the learning-curve.
I too believe that CLJS should be the answer, but the learning curve often gets in the way of the good stuff.
I think that’s kind of my point no? A steep learning curve with sufficient payoff on the other side should be reason enough to climb the curve
Hi, I am working with shadow-cljs
and re-frame
but stucked when use devtools like this
clojurescript
:devtools {:after-load shadow-gen.core/mount-components
:preloads [devtools.preload
day8.re-frame-10x.preload]}
`it shows warnings like this
------ WARNING #3 --------------------------------------------------------------
File: day8/re_frame_10x/view/parts.cljs:30:34
--------------------------------------------------------------------------------
27 | [:h1 "FX"]
28 | (render-registered re-frame.fx/kind)
29 | [:h1 "co-fx"]
30 | (render-registered re-frame.cofx/kind)
----------------------------------------^---------------------------------------
Use of undeclared Var re-frame.cofx/kind
--------------------------------------------------------------------------------
31 | ]])
--------------------------------------------------------------------------------
@sound2gd should have been fixed. not sure if a new version was released yet though. https://github.com/Day8/re-frame-10x/pull/164
I've just cut a new release in https://github.com/Day8/re-frame-10x/releases/tag/0.2.1
(defn hook-browser-navigation! []
(doto (History.)
(events/listen
HistoryEventType/NAVIGATE
(fn [event]
(secretary/dispatch! (.-token event))))
(.setEnabled true)))
and the function hook-browser-navigation!
will cause entire dom been removed, after debug I found it is js-reload
which cause thisthanks, here is my shadow-cljs config
;; shadow-cljs configuration
{:source-paths
["src/cljs" "env/dev/cljs/"]
:dependencies
[[org.clojure/clojurescript "1.9.946"]
[re-frame "0.10.5"]
[reagent "0.7.0"]
[secretary "1.2.3"]
[markdown-clj "1.0.2"]
[cljs-ajax "0.7.3"]
[day8.re-frame/re-frame-10x "0.2.0"]
[binaryage/devtools "0.9.9"]
]
:verbose true
:builds
{:app {:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:dev
{:compiler-options {:closure-warnings {:global-this :off}
:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}
:source-map true
:optimizations :none
:pretty-print true}
}
:modules {:app {:entries [shadow-gen.app]}}
:devtools {:after-load shadow-gen.core/mount-components
;; :preloads [day8.re-frame-10x.preload]
}
}}
}
(defonce history-ref (volatile! nil))
(defn hook-browser-navigation! []
(when-not @history-ref
(let [history (History.)]
(vreset! history-ref history)
(doto history
(events/listen
HistoryEventType/NAVIGATE
(fn [event]
(secretary/dispatch! (.-token event))))
(.setEnabled true)))))
try thisbut a meta like ^:figwheel-no-load
is needed because one can not run init!
and destroy state every time
;; -------------------------
;; Initialize app
(defn mount-components []
(rf/clear-subscription-cache!)
(r/render [#'page] (.getElementById js/document "app")))
(defn init! []
(rf/dispatch-sync [:initialize-db])
(load-interceptors!)
(hook-browser-navigation!)
(mount-components))
init!
only need run once, then use :after-load
taskwell you could do this
(defonce init-complete-ref (volatile! false))
(defn init! []
(when-not @init-complete-ref
(load-interceptors!)
(fetch-docs!)
(hook-browser-navigation!)
(mount-components)
(vreset! init-complete-ref true)))
thanks you , I export my init!
function like this
(defn ^:export init! []
(rf/dispatch-sync [:initialize-db])
(load-interceptors!)
(hook-browser-navigation!)
(mount-components))
and call shadow_gen.core.init_BANG_();
from index.html
and solved thishtml
<script type="text/javascript">
var context = "{{servlet-context}}";
var csrfToken = "{{csrf-token}}";
shadow_gen.core.init_BANG_();
</script>
when is the appropriate time to use each? I tend to use atoms, and I almost never use watchers
personal preference I guess. the "overhead" of atoms without watchers is super minimal so probably safe to always use atom
yeah, I figured the volatile stuff has much less overhead in the clojure-domain, i've just been seeing it a lot more lately
Yeah, I'd use atoms and volatiles as intended. For me, this is helpful to keep one mental model when switching to Clojure where the semantics matter a little more.
Hi! I have a quick newbie question. I am working with Boot and Clojurescript, and I would like to build my code as a library that I can then import as a node module. It would also be fine if I could build my code as a single bundle.js with my exports set as globals, but right now Boot seems to generate a bunch of files (one for each namespace I think). Not sure how to get a single bundle
I have this dream that one day JavaScript may allow for multi-threaded, adopting a memory model similar to Java's. And in that case ClojureScript could perhaps be ready for it. Of course, lots of code would break. But, maybe properly using atoms instead of volatiles would be one tiny bit less than would break. 🙂 https://webkit.org/blog/7846/concurrent-javascript-it-can-work/
It will be strange to see people using core.async outside of a (go)
block in clojurescript
@hmaurer If you use any of the Closure modes (`:whitespace` to :advanced
) you get one file
And if you use :advanced
you need to use ^:export
to make symbols available to JavaScript
also, is there a better way to compile a CLJS project to be imported in webpack/node than to use globals?
I've never used :output-wrapper
. I wonder if that's what it is intended to do. https://clojurescript.org/reference/compiler-options#output-wrapper
There is an option in react native packager to add custom transformer for files. I wonder if I could somehow to use shadow-cljs (or maybe lumo suites better) like a transformer for cljs files. It would be something like this: https://github.com/kristerkari/react-native-css-transformer/blob/master/index.js
@okilimnik I saw your ticket. Didn't have time to look the react-native stuff yet. come on by #shadow-cljs, we can brainstorm later. trying to finish something else first.
I'm using sablono and react and am having trouble with checkboxes
I can get a checkbox to initially show up with the correct state using the :checked
property, but future changes to that property seem to be ignored in the UI
is there anything special/weird about checkboxes?
Well, the language is called "Clojure" and I'd hope ClojureScript as well in the future 😜
Are there any guides/examples of using ClojureScript for back end node projects? Trying to perhaps implement one at work