Fork me on GitHub
#clojurescript
<
2020-05-10
>
Eliraz06:05:15

Hey, I'm trying to move from React to Reagent using shadow-cljs but for some reason I don't understand, I keep getting this message *shadow-cljs - Stale Client! You are not using the latest compilation output!*

Eliraz06:05:21

When I add break points on any piece of code it seems like it gets to it but does not really execute it. not even (js/alert "lala")

p-himik07:05:32

If you don't get an answer here, it might be worth asking at #shadow-cljs

Eliraz07:05:10

yeah I actually copied the question there after I found out theres a channel dedicated to shadow-cljs

Eliraz07:05:12

Thank you though

ssushant06:05:27

Does anyone have experience writing chrome extensions in Clojurescript? What do you use - chromex?

otwieracz08:05:44

Hey! What is currently well-maintained way of doing WebSockest in Clojure? I am looking for effortless way of talking with Clojure data structures back and forth.

otwieracz08:05:47

I was looking at Sente, but it feels like abstraction on abstraction on abstraction.. And using it with component on backend it pretty much guesswork.

p-himik10:05:35

Why does it feel that way? And what makes it a guesswork?

simongray13:05:04

I haven't had the need for Sente myself, by I would urge you to take a second look at it. Zach Tellman is a fantastic asset to this community. He maintains lots of high-performance Clojure/Java libraries, has many interesting talks, and wrote the awesome book Elements of Clojure that really underscores just how much hammock time is behind his open source stuff.

simongray13:05:01

Basically, he makes good stuff and the abstractions are probably there for a very good reason.

dpsutton13:05:06

I don’t believe sente is a Zach library

p-himik13:05:42

Yep, it's by Peter Taoussanis. Still a great software engineer though, with many OSS projects.

simongray16:05:01

Woops, my bad, but most of what I wrote luckily still applies 😅

simongray16:05:33

I guess I thought of Zach because he is a master of abstractions (manifold) and made Aleph which also has a websocket component.

otwieracz20:05:43

Well, honestly I am just having difficulties with getting it to work and due to it complexity I’ve got issues finding the cause.

otwieracz20:05:11

eg.

Sun May 10 22:27:20 CEST 2020 [worker-1] ERROR - GET /chsk
java.lang.IllegalStateException: close handler exist: taoensso.sente.server_adapters.http_kit.HttpKitServerChanAdapter$fn__48045@46087ec
	at org.httpkit.server.AsyncChannel.setCloseHandler(AsyncChannel.java:197)
	at org.httpkit.server$eval20613$fn__20626.invoke(server.clj:151)
	at org.httpkit.server$eval20514$fn__20584$G__20505__20591.invoke(server.clj:96)
	at taoensso.sente.server_adapters.http_kit.HttpKitServerChanAdapter.ring_req__GT_server_ch_resp(http_kit.clj:25)
	at taoensso.sente$make_channel_socket_server_BANG_$fn__26730.invoke(sente.cljc:638)

otwieracz20:05:35

With all those layers one on top of another it’s super difficult for me.

otwieracz20:05:53

I don’t even know really where to start.

hindol21:05:53

I have used pure Jetty websockets (via Pedestal) and haslett/gniazdo for CLJS client. You need to do your own ping/pong to keep the connection alive. And your own auth.

hindol21:05:31

I too felt Sente is overly complicated.

p-himik03:05:24

@UB0EMUD34 Impossible to say anything definitive without the code that calls ajax-get-or-ws-handshake-fn. Seems like you call hk/on-close twice on the same object.

otwieracz05:05:05

@U2FRKM4TW there isn’t really too much code…

(GET  "/chsk" req (ring-ajax-get-or-ws-handshake req))

otwieracz05:05:34

And component:

:sente (new-channel-socket-server nil
                                     (sente-http-kit/get-sch-adapter)
                                     ;; 
                                     {:csrf-token-fn nil
                                      :allowed-origins #{""}
                                      })

otwieracz05:05:51

And in cljs:

(defonce sente-socket
  (sente/make-channel-socket! "/chsk" nil
                              {:type :auto
                               :port 8080
                               }))

otwieracz05:05:12

I am just trying to get it working somehow 🙂

p-himik06:05:46

Yeah, it seems like you're hitting that issue. I don't know how to fix it by doing anything short of reproducing and debugging it. If you can create a minimal reproducible example (definitely without the component library) and post it in the issue, it definitely could be helpful to those that will try to fix it. I doubt it will be me though. :) I use Sente with Aleph, so far it has been perfect.

otwieracz06:05:28

With Aleph it seemed like I will be adding another variable into the stack.

p-himik06:05:40

How is that different from http-kit in that regard? I use Aleph instead of http-kit.

otwieracz07:05:18

Well, I already have http-kit for statics 🙂

otwieracz07:05:11

And I don’t like working around things that way. You know, at some point I will indeed need http-kit and then what..

otwieracz07:05:24

Either way, I will try to invest more time into that.

👍 4
sova-soars-the-sora16:05:12

start with the working sente clone

Eliraz17:05:29

anyone tried the new functional-compiler of reagent? how would I know that Reagent actually creating function components and not Class components? I mean how can I see the React code that comes out ?

athomasoriginal15:05:17

Hi 🙂 You can always look into the JS generated by ClojureScript (either in the browser or in the output dir generated by CLJS). You could log your components and see what they output. In general though, one way to know if a component is a Class or Function component is if the component has a isReactComponent flag. see https://overreacted.io/how-does-react-tell-a-class-from-a-function/ and for more information about how a class component is transformed in Reagent https://betweentwoparens.com/what-the-reagent-component