Fork me on GitHub
#fulcro
<
2020-01-20
>
minhnn01:01:03

I do this example

minhnn01:01:09

when i load this code to repl

minhnn01:01:20

(ns app.client
  (:require
    [com.fulcrologic.fulcro.application :as app]
    [com.fulcrologic.fulcro.components :as comp :refer [defsc]]
    [com.fulcrologic.fulcro.dom :as dom]
    [com.fulcrologic.fulcro.algorithms.merge :as merge]
    [com.fulcrologic.fulcro.algorithms.data-targeting :as targeting]))



(defsc Car [this {:car/keys [id model] :as props}]
  {:query [:car/id :car/model]
   :ident :car/id}
  (dom/div
    "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}
  (dom/div
    (dom/div "Nameeee: " name)
    (dom/div "Age: " age)
    (dom/h3 "Carssssss")
    (dom/ul
      (map ui-car cars))))

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

(defsc Sample [this {:root/keys [person]}]
  {:query [{:root/person (comp/get-query Person)}]}
  (dom/div
    (ui-person person)))

(defonce APP (app/fulcro-app))

(defn ^:export init []
  (app/mount! APP Sample "app"))

(comment

  (reset! (::app/state-atom APP) {})

  (swap! (::app/state-atom APP) update-in [:person/id 2 :person/age] inc)

  (merge/merge-component! APP Person {:person/id   2
                                      :person/name "Bob"
                                      :person/age  21
                                      :person/cars [{:car/id    1
                                                     :car/model "F-150"}]}
                          :replace [:root/person])


  (app/current-state APP)
  (app/schedule-render! APP))

minhnn01:01:03

I got this error `Syntax error compiling at (src/app/client.cljs:14:3). No such var: com.fulcrologic.fulcro.dom/macro-create-element*`

tony.kay02:01:20

Typo in the book. That function is in some other ns from 2.x to 3.x…pls indicate a link to the section of the book

thomas19:01:17

Hi, I am trying to implement a progress update where the information is coming from the server. I have implemented an UISM as per suggestion from last Thursday/Friday and I can generate the events to set a timer and then generate a new event. But how can I force a reload of the data on an event?