Closed cgrand closed 5 years ago
Each template could be seen as a rule:
[(item [?id]) [?id :item/title]]
(in practice it should be more filtered)
[(item-detail [[?id] ?title ?done]) [?id :item/title ?title] [?id :item/done ?title]]
Having a single query would mean having spare columns and reusing these spares across sibling templates (not sibling components: really sibling templates).
With two queries we would have [:find ?id :where (items ?id)]
and [:find ?id ?title ?done :where (items ?id) (item-detail id ? title ?done)]
Derivation could leverage the nesting: derivation of the second query should not return retractions that are a consequence of the item being retracted, only retractions due to a change in title or status.
Thus when the row for a component is retracted we don't get retractions for its children which is not useful.
Another point to keep in mind: multiple queries -> multiple subscriptions -> multiple handlers As a consequence it may means transacting the state of the component hierarchy multiple times as a consequence of a single tx.
It's not good. We must have 1 tx -> 1 ui transact -> 1 render.
And/or we must be careful to not trigger on ui transacts.
It will be one query per template.
(todo list example)
If each component has its own query then for a todo-list of N items we get at least N+1 subscriptions (1 for the list and N for each item).
Having 2 queries sounds better; is it even doable to have only 1 query?