Closed thedavidmeister closed 1 year ago
I prefer to put all server app state in an atom and then use this:
(defn add-sente! [state]
(let [{:keys [ch-recv send-fn connected-uids
ajax-post-fn ajax-get-or-ws-handshake-fn]}
(sente/make-channel-socket! (get-sch-adapter) {})]
(-> state
(assoc-in [:sente :ring-ajax-post] ajax-post-fn)
(assoc-in [:sente :ring-ajax-get-or-ws-handshake] ajax-get-or-ws-handshake-fn)
(assoc-in [:sente :ch-chsk] ch-recv) ; ChannelSocket's receive channel
(assoc-in [:sente :chsk-send!] send-fn) ; ChannelSocket's send API fn
(assoc-in [:sente :connected-uids] connected-uids) ; Watchable, read-only atom)
)))
to add sente channels. I really don't like defing app state in a namespace.
Will be included in forthcoming v1.18 release, apologies for the long delay.
Hi, I've been using sente in an app that uses
boot
andwatch
.At some point,
watch
started causing my websockets to not be able to connect after I refresh the page.It seemed to help using
defonce
instead ofdef
in this code: