Skip to content

Commit e79325c

Browse files
committed
refinements
1 parent 6254d9a commit e79325c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
.#*
77
.DS_Store
88
.lein-repl-history
9-
.nrepl-port
9+
.nrepl-port
10+
node_modules/

src/system/components/sente.cljc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,27 @@
4949

5050
;; Sente does not support CLJ as a client yet
5151
#?(:cljs
52-
(defrecord ChannelSocketClient [chsk ch-chsk chsk-send! chsk-state router path handler options]
52+
(defrecord ChannelSocketClient [chsk ch-chsk chsk-send! chsk-state path router handler options]
5353
component/Lifecycle
5454
(start [component]
55-
(let [handler (or handler (get-in component [:sente-handler :handler]))
56-
{:keys [chsk ch-recv send-fn state]}
57-
(sente/make-channel-socket-client! path options)]
58-
(assoc component
59-
:chsk chsk
60-
:ch-chsk ch-recv
61-
:chsk-send! send-fn
62-
:chsk-state state
63-
:router (atom (sente/start-chsk-router! ch-recv (if (:wrap-component? options)
64-
(handler component)
65-
handler))))))
55+
(let [{:keys [chsk ch-recv send-fn state]} (sente/make-channel-socket-client! path options)
56+
component (assoc component
57+
:chsk chsk
58+
:ch-chsk ch-recv ; ChannelSocket's receive channel
59+
:chsk-send! send-fn ; ChannelSocket's send API fn
60+
:chsk-state state)]
61+
(if handler
62+
(assoc component :router (atom (sente/start-chsk-router! ch-recv handler)))
63+
component)))
6664
(stop [component]
6765
(if-let [stop-f (and router @router)]
6866
(assoc component :router (stop-f))
6967
component))))
7068

7169
#?(:cljs
7270
(defn new-channel-socket-client
71+
([]
72+
(new-channel-socket-client nil "/chsk" {}))
7373
([path]
7474
(new-channel-socket-client nil path {}))
7575
([event-msg-handler path]

0 commit comments

Comments
 (0)