Fork me on GitHub

Hi, I’m trying to fill Fulcro in the bucket of my head… In the tutorial there’s two PersonLists and each PersonList have multiple Persons. There are two PersonLists so they all have ident. What if I just have a global singleton list, can I have a normalized result without given the singleton an identity? More specifically the following code:

(defsc TodoItem [this {:keys [db/id todo/text]}]
  {:query         [:db/id :todo/text]
   :ident         [:todo/by-id :db/id]
   :initial-state (fn [{:keys [id text]}] {:db/id id :todo/text text})}
  (let [delete #(transact! this `[(delete-todo-item {:id ~id})])]
     (span text)
     (button {:onClick delete} "-"))))

(def ui-todo-item (factory TodoItem {:keyfn :todo/text}))

(defsc Root [this {:keys [ui/react-key todos]}]
  {:query         [:ui/react-key
                   :todos (get-query TodoItem)]
   :initial-state (fn [params] {:todos [(get-initial-state TodoItem {:id 1 :text "first"})
                                        (get-initial-state TodoItem {:id 2 :text "second"})
                                        (get-initial-state TodoItem {:id 3 :text "third"})]})}
  (map ui-todo-item todos))
would result the following database:
{:other-keys ...
 [{:id 1 :text "first"}
  {:id 2 :text "second"}
  {:id 3 :text "third"}]}
So there’s no :todo/by-id table I declared in the query of TodoItem. If I remove the level of :todos it seems I have to put entities at the top level without table. Am I doing it wrong or if I need top level normalised entities table I have to provide identity all the way down to the entities I want to normalise?


Is there any documentation out there about installing and running falcro on windows? I made an attempt, but was unable to successfully run shadow-cljs. After some research it seems like the configuration that comes out of the lein template is incompatible with windows.


@clojuriansinvite how so? I'm on windows myself


is windows decent these days for development? or do you have masochistic tendencies?


I'm pretty happy with it


@U5ZAJ15P0 Since Azure became Microsoft's #1 priority Windows development has massively improved, and will continue to improve. That being said, I'm on windows because I wont buy Apple, and there is a lot of software I like to use that does not run on Linux.


@U05224H0W. When I try to run shadow-cljs, it complains it can't find clojure. This is despite clojure definitely being on my system path.


shadow-cljs - starting via "clojure"
Executable 'clojure' not found on system path.


@clojuriansinvite if you run clj in your terminal, does that work?


Yes, running both clj and clojure in the terminal works


ah right. yeah the clj and clojure versions on windows are something powershell related


dunno how to call that properly


works fine if you just use plain shadow-cljs.edn without deps.edn


or WSL works too


@U05224H0W I've been using WSL in the mean time, but I would prefer it if I could avoid it.


it sort of depends on the missing clojure executable. I need to look at how the powershell implementation works since I don't know why thats different


but I should be able to detect it somehow


Think I figured out the above by using prim/with-parent-context to thread this through to my wrapped Fulcro components, but now I have a different issue. Root’s query looks like {:current-screen (prim/get-query Screen)}, and then my individual screens are querying for [:screen/id], with ident [:screens/by-id :screen/id]. Essentially what’s happening is that by using ident/link queries on :current-screen from root, mutating that value is causing root to re-render (obviously), but this is stepping on react-navigation which apparently assumes it has control of root rendering. I believe I might need to make use of the reconciler’s shared-fn to store :current-screen, and then each screen can “root themselves” on that shared state. I can hook into react navigation’s events in order to set :current-screen…is this an acceptable use of shared-fn :thinking_face: