Fork me on GitHub

is there a library for state management along the lines of reagent/re-frame without the UI pieces?


Tuck is a minimalistic one:


(reagent being a dependency is a dealbreaker for me - i'm writing a console application)


ok, I misunderstood… I thought you specifically wanted for react development


oh wow, derivatives is actually quite simple


Some folks at nilenso wrote this small lib recently: Thoughts?


To be fair I don’t really see the point of using this how it’s now since it’s so minimal. There is no reconnect, and no check if the channel is open before sending. It’s nice to see it’s specced. I use the js websocket in my current webproject with a nginx websocker in the back-end.


Yeah, I think the idea is to add retries for connection and some basic error handling as well. It’s in the issues.


ok, could be nice then, took me a while to figure that out for myself.

Geoffrey Gaillard08:09:57

I spent the night trying to figure out how cross-module code motion works with cljs 1.9.908 but I can't solve my problem and need some help. I have a simple build with two modules as in :

{:output-dir    "resources/public/js/out"
 :asset-path    "/js/out"
 :optimizations :whitespace
 :modules        {:core  {:entries   #{app.core}
                          :output-to "resources/public/js/out/core.js"}
                  :pages {:entries   #{app.pages}
                          :output-to "resources/public/js/out/pages.js"}}}
So this produces 3 files, core.js, pages.js and cljs_base.js. But here is the trick: on :optimizations :none everything works fine. By 'fine' I mean that cljs_base.js is successfully evaluated by the browser, then core.js and pages.js. But on :optimizations :whitespace or :advanced some namespaces are moved down the deps tree to one of the splits, even if they are required by namespaces that ends up in cljs_base. The produced cljs_base.js is broken and fail to load in the browser with (in my case) :`Uncaught Error: goog.require could not find: goog.color.names`. Building modules … entries from the compiler's logs did shown me that some namespaces got moved down while they should stay in the cljs_base. I don't understand why …

Geoffrey Gaillard13:09:21

I'm really struggling with that and I start to suspect a bug suspect . I'll make a small project and try to reproduce this


does defmethod belong in the clj portion of the code or the cljs?


I think it depends

Geoffrey Gaillard12:09:26

@gfredericks if I understand your question correctly, you can use defmulti/`defmethod` both in clj and cljs. It works the same way. What do you find confusing in this feature ?


@ggaillard I'm dealing with something more subtle. If I understand it correctly, cljs.test/assert-expr is a clj multimethod, so it has to be extended from clj code in the same place that you put macros. And this is problematic for a cljc project where you can't assume cljs.test exists


I think I fixed it with dynamicity, but it's unfortunate to have to resort to that

Geoffrey Gaillard13:09:25

:thinking_face: indeed. cljs.test/assert-expr is defined in a cljc file, it will be expanded during the compilation phase (phase 1, clojure side) into cljs code that will then be compiled to js (phase 2). If you try to implement macros on top of it you can put them in a cljc file and use reader conditionals #?{:clj …, :cljs …}. This way you can ensure that cljs.test exist.


I don't think reader conditionals works


you have to put everything in the :clj side


to be clear my code has (defmethod cljs.test/assert-expr ...) in it, and that needs to go on the :clj side


I think this is the same as the more traditional problem of macros that are sensitive to which environment you're in


but apparently requires more tricks to solve

Geoffrey Gaillard13:09:14

And when you put (defmethod cljs.test/assert-expr ...) on the :clj side, you get an error that cljs.test do not exist ?


although I'm confused what causes that error


everything builds fine for clj and cljs via leiningen, but the maven build for clj fails with that error


even though I see a dependency on clojuscript


the commit before that one fails for mvn test