taoensso / sente

Realtime web comms library for Clojure/Script
https://www.taoensso.com/sente
Eclipse Public License 1.0
1.74k stars 193 forks source link

Should we check for a nil value in start-chsk-router! ? #312

Closed boldaslove156 closed 1 year ago

boldaslove156 commented 6 years ago

I was playing with sente and mount and basically I have 2 states created using defstate : sente and sente-listener.

(defstate sente
  :start (make-channel-socket! aleph-adapter {:packer transit-packer})
  :stop (async/close! (:ch-recv sente)))

(defstate sente-listener
  :start (start-chsk-router! (:ch-recv sente) callback-fn)
  :stop (sente-listener))

mount has this nice feature that when you eval the given state it will automatically :stop then :start . In this case eval-ing sente only will result on an infinite loop since the :ch-recv channel is closed.

What do you think if start-chsk-router! also has to check nil value in addition to its own ch-ctrl ?

ptaoussanis commented 6 years ago

Sounds good to me, PR welcome- thanks! :+1:

ptaoussanis commented 1 year ago

Closing for inactivity, as part of issue triage. Please feel free to re-open if this issue is still relevant - thanks!

I would implement this myself, but I don't understand the following:

What do you think if start-chsk-router! also has to check nil value in addition to its own ch-ctrl ?

What do you mean exactly by "check nil value in addition to its own ch-ctrl"?