Fork me on GitHub
#clojurescript
<
2017-09-19
>
cjhowe05:09:05

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

tatut05:09:08

Tuck is a minimalistic one: https://github.com/tatut/tuck

cjhowe05:09:56

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

tatut05:09:31

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

cjhowe19:09:54

oh wow, derivatives is actually quite simple

srihari06:09:31

Some folks at nilenso wrote this small lib recently: https://github.com/nilenso/wscljs. Thoughts?

gklijs11:09:12

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.

srihari11:09:35

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

gklijs12:09:36

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

gfredericks12:09:28

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

gfredericks12:09:09

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 ?

gfredericks13:09:35

@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

gfredericks13:09:49

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.

gfredericks13:09:49

I don't think reader conditionals works

gfredericks13:09:02

you have to put everything in the :clj side

gfredericks13:09:52

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

gfredericks13:09:27

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

gfredericks13:09:00

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 ?

gfredericks13:09:54

although I'm confused what causes that error

gfredericks13:09:10

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

gfredericks13:09:16

even though I see a dependency on clojuscript

gfredericks13:09:52

the commit before that one fails for mvn test