Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Unmounting" zelkova #9

Open
bensu opened this issue Jun 19, 2015 · 1 comment
Open

"Unmounting" zelkova #9

bensu opened this issue Jun 19, 2015 · 1 comment

Comments

@bensu
Copy link
Contributor

bensu commented Jun 19, 2015

If I have an om component that starts a live graph when mounted, I would like to take the graph down when unmounting it. Is this possible? I'm currently doing something like this:

(defn pipe-to-atom
  "Adds live-graph to the return value of the original z/pipe-to-atom"
  [x]
  (let [live-graph (z/spawn x)]
    [(z/pipe-to-atom live-graph
       (atom (zimpl/init live-graph)
         :meta {::source live-graph}))
     live-graph]))

(defn zortable [data owner opts]
    (reify
      om/IWillMount
      (will-mount [_]
        (let [signal (state-signal opts)
              [state-ref live-graph] (pipe-to-atom signal)]
          (add-watch state-ref ::sortable
            (fn [_ _ _ nv]
              (om/update-state! owner #(merge % nv))))
          (om/set-state! owner :live-graph live-graph)
          (om/set-state! owner :state-ref state-ref)))
      om/IWillUnmount
      (will-unmount [_]
        (async/close! (om/get-state owner :live-graph)))
      ...)

The only thing I figured out was to async/close! the live-graph since it implements the protocol but it is not enough. After the component is unmounted, zelkova's event listeners still put! values in channels which raises the following exception on each mouse movement:

Uncaught Error: Assert failed: No more than 1024 pending puts are allowed on a single channel. Consider using a windowed buffer. (< (.-length puts) impl/MAX-QUEUE-SIZE

@jamesmacaulay
Copy link
Owner

Thanks for the report, I'm not sure why this is happening. The intention is definitely that you should be able to close! a graph when you're done with it. I'll have to do some investigation to see where channels are not being closed when I expect them to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants