Fork me on GitHub
#re-frame
<
2020-01-28
>
Endre Bakken Stovner13:01:02

Web-noob here trying to learn re-frame. I am trying to make a same machine clj+cljs app; clj for the logic and cljs for visualization. I want to send messages to the front-end from the back-end. What is the best way to do this? The idea is that the clj app should send messages to the re-frame app so that re-frame automatically updates the webpage. I would like to avoid using a database if possible. Thanks.

p-himik13:01:15

I use transit over WebSockets backed by Sente.

Endre Bakken Stovner13:01:16

I will look into it, thanks 🙂

simongray14:01:16

@UT770EY2K transit is the best answer (transit is awesome). You don’t need to use websockets or sente, though.

👍 8
Endre Bakken Stovner11:01:31

Yes, that one seems even simpler. Thanks :)

Endre Bakken Stovner14:01:51

Okay, but transit is just for reading and writing the data, right? I guess you would need something like sente to actually send the data back and forth? I do not understand how transit actually would help to send data back and forth between clj/cljs.

p-himik17:01:29

Yes, Transit is but a data format. There are multiple libraries that convert your data into Transit and back. As for the data transfer - you can use anything that can handle JSON (since Transit is backed by JSON by default, although it can be changed as well if you like). Regarding how Transit would help. How else would you send e.g. a set, something like #{1 2 3}? The obvious solution is EDN, but there are thee issues with it: 1. It's usually slower since it doesn't rely on any existing technology that has been polished to its limits (like JSON or msgpack) 2. The tooling support is rather weak (e.g. in the Network tab of the Google Chrome DevTools, the browser will detect JSON allowing you to explore the value, but it won't detect EDN, displaying it just as a string) 3. The implementations for other languages are not as abundant and ready to use. That's not an issue if you won't have any parties written in other languages.

👍 4