Fork me on GitHub
#hyperfiddle
<
2023-03-05
>
nakkaya20:03:56

I am trying to structure how to do push notifications in my use case, I am using electric to receive large files (+100MB) I have a separate ring route that accepts a POST request and from electric I just initiate a POST request with the file, I am running a bunch of ML models which take quite bit of time after a while I would like to send a notification and/or update the users UI with the results. Is there an example that shows how to do something similar that I can use as a blue print?

👀 2
2
Dustin Getz20:03:30

can you toggle an atom or cons a list in the atom? see demo-chat

nakkaya21:03:42

If I use the approach in demo-chat and update an atom on the clj side, will the atom be shared among all users or will each user get an instance of it?

Dustin Getz21:03:19

ah, the atom is only shared if it is global. If you allocate an atom in lexical scope on the server it will be bound to the websocket session. If you need the state to persist across sessions you would want to use a database (or a "fake" database which is a durable atom in global scope, back it by disk or dynamodb or something)

nakkaya22:03:12

> If you allocate an atom in lexical scope on the server it will be bound to the websocket session. Just to make sure I got this right, if I bind the atom in a e/defn inside a e/server block each websocket session gets their own atom instance on the server side, nothing leaks between users.