On Saturday, August 30, 2014 8:24:19 PM UTC-5, Daniel Kersten wrote:
Something like this:
(defn component [data owner]
(reify
om/IInitState
(init-state [_]
(let [chan (chan)]
{:chan chan
:kill (chan)
:pub (pub chan first)}))
Perfect! Closing the channel is simpler than using a kill channel (in the
cases when its possible to do this - if something else owns the channel
then you can't use this method of course).
On 1 September 2014 11:41, Dhruv Bhatia dh...@dhruvbhatia.com wrote:
Thanks for reviewing my solution
I use a mixin for this purpose all the time!
(defmixin go-loop-aware
(init-aware [owner]
{:chans {:mounted (async/chan)}})
(will-unmount [owner]
(async/close! (om/get-state owner [:chans :mounted])))
(go-loop-aware [owner read-chan callback]
(when
I assume that (! subscriber-ch)will return nil when subscriber-ch is
closed? I vaguely remember this to be the case, though have not tested it.
If it does, then your way looks good to me.
On 31 August 2014 02:40, Dhruv Bhatia dh...@dhruvbhatia.com wrote:
Thanks a lot.
I managed to create a
On Sunday, 13 July 2014 01:46:41 UTC+10, Daniel Kersten wrote:
Channels are cheap, but unless they get garbage collected (and I assume not
closing them will prevent this), they will still take up some resources.
Related and important is that you shut down any go blocks that you create in
Something like this:
(defn component [data owner]
(reify
om/IInitState
(init-state [_]
(let [chan (chan)]
{:chan chan
:kill (chan)
:pub (pub chan first)}))
om/IWillMount
(will-mount [_]
(let [pub (om/get-state owner :pub)
chan
Thanks a lot.
I managed to create a solution which doesn't require a separate kill-channel.
It seems to be side-effect free and cleans up as expected, though I'm still
quite new to Clojurescript and core.async so I may be wrong!
; UTIL.CLJS
; PUB/SUB SETUP
; create a global events-ch channel
Channels are cheap, but unless they get garbage collected (and I assume not
closing them will prevent this), they will still take up some resources.
Related and important is that you shut down any go blocks that you create
in IWillMount, especially if they take from a channel which may still be
I'm using Om for the client side and through the lifetime of the application
many components gets mounted/unmounted. When mounted, various channels are
opened (in go blocks). And I'm planning to use IWillUnmount to close them too.
But first, my questions are: What happens to unclosed channels?