Fork me on GitHub
Timofey Sitnikov11:02:42

Good Morning! In the code below, from, branch full-stack-1, looking at the code below, why is it that the :ident of PersonList is in the [:component/id ::person-list], but both the Person and the Car is in :person/id and :car/id, why not place the Person and the car into [:component/id :person/id] and [:component/id :car/id] ?

(defsc Car [this {:car/keys [id model] :as props}]
  {:query [:car/id :car/model]
   :ident :car/id}
    "Model " model))

(def ui-car (comp/factory Car {:keyfn :car/id}))

(defsc Person [this {:person/keys [id name age cars] :as props}]
  {:query [:person/id :person/name :person/age {:person/cars (comp/get-query Car)}]
   :ident :person/id}
  (let [onClick (comp/get-state this :onClick)]
    (div :.ui.segment
      (div :.ui.form
        (div :.field
          (label {:onClick onClick} "Name: ")
        (div :.field
          (label "Age: ")
        (dom/button :.ui.button {:onClick (fn []
                                            (comp/transact! this
                                              [(make-older {:person/id id})]
                                              {:refresh [:person-list/people]}))}
          "Make Older")
        (h3 {} "Cars")
        (ul {}
          (map ui-car cars))))))

(def ui-person (comp/factory Person {:keyfn :person/id}))

(defsc PersonList [this {:person-list/keys [people]}]
  {:query         [{:person-list/people (comp/get-query Person)}]
   :ident         (fn [] [:component/id ::person-list])
   :initial-state {:person-list/people []}}
  (let [cnt (reduce
              (fn [c {:person/keys [age]}]
                (if (> age 30)
                  (inc c)
    (div :.ui.segment
      (h3 :.ui.header "People")
      (div "Over 30: " cnt)
        (map ui-person people)))))

(def ui-person-list (comp/factory PersonList))


The idents are not working quite like that. The function form returns an exact ident, it literally is that vector. The short form is actually building the ident from the id datum that the component gets


If you run the example, you see where the actual data ends up: PersonList has data under {:component/id {::person-list {data}}. Person has data under {:person/id {1 {data} 2 {data} 3 {data}} and so on

Jakub Holý (HolyJak)16:02:56

Exactly. You use the former, static idents for "singleton" components and the latter dynamic ident for components that display one of many possible data entities. So you have just a single list but many persons.

Timofey Sitnikov16:02:54

@U8ZQ1J1RR, so when I run the app, and do Fulcro inspect, I get this:

Timofey Sitnikov16:02:59

Does that look right?

Timofey Sitnikov16:02:27

Wow, when I run the, branch full-stack-1 with upgraded pathom to 2.4.0, I get wrong results. So blow is the result with pathom 2.2.4 and the second one is the pathom 2.4.0. Is pathom 2.4.0 compatible with latest Fulcro?


the newer versions of Pathom use guardrails...perhaps your server is throwing exceptions now?


should not be a compatibility problem

Timofey Sitnikov19:02:43

OK, maybe thats what it is. The Video Series does not include guardrails.