Fork me on GitHub
#hoplon
<
2018-01-18
>
flyboarder00:01:40

@thedavidmeister what tasks from hoplon are you running in the project?

flyboarder01:01:03

yeah I saw but in the other project

flyboarder02:01:25

weird, what does the build.boot look like?

thedavidmeister04:01:24

is there a particular part you're interested in?

flyboarder04:01:20

just the calls to hoplon tasks

flyboarder04:01:37

and where you require hoplon

thedavidmeister04:01:37

kk, just deep in something atm, will post in a bit

thedavidmeister12:01:47

hmmm i think i found a bug in merge-kids, or i'm trying to do something it wasn't designed to handle

thedavidmeister12:01:44

if you do like (div el-1 items el-2) and then shuffle items (the actual els, not just the data in a for-tpl) then somehow el-2 ends up mixed in with the items

thedavidmeister12:01:29

this seems to work better

thedavidmeister12:01:33

(defn- merge-kids
  [this _ new]
  (let [new  (->> (vflatten new) (reduce #(if (nil? %2) %1 (conj %1 %2)) []) (mapv ->node))
        old (child-vec this)]
   (loop [[o & os] old
          [x & xs] new]
    (when (or o x)
     (cond
      ; do nothing if no changes
      (= x o) nil

      ; if there is a new child swap out the old one
      (and x o) (.replaceChild this x o)

      ; add new items
      x (.appendChild this x)

      ; remove old items
      o (.removeChild this o))
     (recur
      ; ensure we don't re-process x as an o later or replaceChild will do bad
      ; things
      (remove #{x} os)
      xs)))))

thedavidmeister12:01:02

notably i'm doing a replaceChild instead of an insertBefore

thedavidmeister12:01:21

i'm open to feedback on this one 🙂

flyboarder17:01:08

@thedavidmeister i think that looks like a cleaner form of merge-kids