cgrand / enlivez

8 stars 0 forks source link

Day #7 #16

Closed cgrand closed 5 years ago

cgrand commented 5 years ago

Thinking out loud about what happens at runtime (todo list example).

  1. A new item is added to the database.
  2. It triggers the LQ for the with, this LQ emits a path [0] [] [12345] ["title" false]: [0] is the key in the root fragment (the one with the <ul>) to identify its first and only child: the with. Then [] is additionals values (always empty fro fragments) then a key anew [12345] this time its the eid of the new item, it's the identifier of the iteration, and then additional values.
    1. The thing that bugs me at the moment is that terminal (foreign) templates don't have queries and thus need support from the fragment and with to render: the with must pass its "additional values" to the fragment which must pass them to its terminals and implement logic of checking which values have changed!
    2. Let's imagine a world where we get 3 paths [0] [12345], [0] [12345] [0] ["title"] and [0] [12345] [1] [false] then, in this world, we have full selectivity and all the diffing logic is removed from fragments etc. We also don't have the keys/other vals split
cgrand commented 5 years ago

Okay, it simplifies things to switch to query-all-the-things and we get these paths:

([[?child12620] [[(ground 0) ?child12620]]] [#{?id12623} [[?id12623 :item/title title] [?id12623 :item/status status]]])
([[?child12620] [[(ground 0) ?child12620]]] [#{?id12623} [[?id12623 :item/title title] [?id12623 :item/status status]]] [[?child12624] [[(ground 0) ?child12624]]] [[title] []])
([[?child12620] [[(ground 0) ?child12620]]] [#{?id12623} [[?id12623 :item/title title] [?id12623 :item/status status]]] [[?child12624] [[(ground 1) ?child12624]]] [[status] []])

which translate to:

[:find ?child12620 ?id12623 :where [(ground 0) ?child12620] [?id12623 :item/title title] [?id12623 :item/status status]]
[:find ?child12620 ?id12623 ?child12624 title :where [(ground 0) ?child12620] [?id12623 :item/title title] [?id12623 :item/status status] [(ground 0) ?child12624]]
[:find ?child12620 ?id12623 ?child12624 status :where [(ground 0) ?child12620] [?id12623 :item/title title] [?id12623 :item/status status] [(ground 1) ?child12624]]
cgrand commented 5 years ago

Let's go back to step 2.

  1. It triggers the LQs and we get (actual order may vary) three additions: [[0] [12345]], [[0] [12345] [0] ["title"]] and [[0] [12345] [1] [false]].
  2. we processes these paths either one by one or in lockstep; at each step we ensure there's a component for the path. Ensuring a component may instantiate it.
cgrand commented 5 years ago

Let's consider this protocol:

(defprotocol Component
  (ensure! [c k] "Returns the child component")
  (delete! [c k] "Deletes the child component"))