Table of Contents
Setup
Add to project:
(ns ...
(:require [reframe-websocket.core :as reframe-websocket]))
Reframe :set and :get event/subscription registration
This will create an event handler called :get
and a subscription
handler called :set
to be used like:
(reframe/dispatch-sync [:set [:some :path] "abc123"])
;; sets the path [:some :path] to value "abc123" in the app-db
@(reframe/subscribe [:get [:some :path]])
;; => "abc123"
Send/Recv to Server
Define your endpoint
(def my-aws (reframe-websocket/async-websocket "ws://localhost:7890"))
Send to Server
;; Send a message, specify where to store the response
(let [my-message {:my-message "blah" :some-param 12345}
my-store-location [:store :path]]
(reframe-websocket/send-msg my-message my-store-location my-aws))
;; retrieve the response
@(reframe/subscribe [:get [:store :path]])