Skip to content

"Unmounting" zelkova #9

@bensu

Description

@bensu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions