cgrand / enlivez

8 stars 0 forks source link

Day #2 #7

Closed cgrand closed 5 years ago

cgrand commented 5 years ago

What is the runtime model of the UI? A hierarchy of components.

When a delta arrives we get a long row, which can be split into stages (see rules in #4) , each stage mapping to a component into the hierarchy. If there's no component then it should be instantiated.

Let's imagine (syntax with #5):

[:ul
 (with [[item :item/title]]
   [:li (:item/title item) " is " (if (:item/done item) "done" "to do")])]

Here I count 4 templates:

Which would mean 3 queries

The last two would need to be differentiated by adding an id (the mount point id for example): [[item :item/title] [(ground :mount_421) mnt] [(get-else item :item/done nil) done]]

Thus such code should work:

(defn add [{:as component :keys [n instantiate]} row]
  (if (seq row)
    (let [k (subvec row 0 n)]
      (update-in component [:children k]
        (fn [child]
          (add (or child (instantiate k) (subvec row n))))))
    component))

It's too functional/persistent for something which is linear.

cgrand commented 5 years ago

By linear, I mean that actual nodes may be updated or mutated and we don’t care because they are never shared.