 (defmulti unify!
   "Given container, data, and mapping-fn, calls (mapping datum idx) for each datum and appends resulting elements to container.
 Automatically updates elements mapped to data according to key-fn (defaults to index) and removes elements that don't match.
-Scoped to selector kwarg, if given, otherwise applies to all container's children.
-Optional enter, update, and exit functions called before DOM is changed; return false to prevent default behavior.
+Scoped to :selector kwarg if given, otherwise applies to all container's children.
+
+Optional kwargs fns (args prefixed with $ are live DOM nodes):
+
+  (enter d idx $node)
+  (update d idx $old new)
+  (exit d idx $node)
+
+called before DOM changed; return false to prevent default behavior.
+
 If data implements IWatchable, DOM will update when data changes."
   (fn [container data mapping & kwargs]
     (cond (satisfies? cljs.core.IWatchable data) :atom

          (do
            ;;append it (effectively moving it to the correct index in the container)
            (append! container (:node old))
            ;;If its data is not equal to the new data, update it
            (if (or (not= d (:datum old)) force-update)
              (if (update d idx (:node old) new-node)
                (attach-data (merge-dom! (:node old) new-node
                                         :defer-attr defer-attr)
                             d))))

          ;;instantiate new node on the DOM so it can be manipulated in the user-specified `enter` fn.
          (let [new-dom-node (append! "body" new-node)]
            (attach-data new-dom-node d)
            (if (enter d idx new-dom-node)
              (append! container new-dom-node) ;;move new node to container
              (remove! new-dom-node))))))

    ;;Run post-fn, if it was given
    (if post-fn

    (doseq [k (set/difference (set (keys existing-nodes-by-key))
                              (set (map key-fn data (range))))]
      (let [{:keys [node idx datum]} (existing-nodes-by-key k)]
        (when (or (nil? exit)
                  (exit datum idx node))
          (remove! node))))


