This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-23
Channels
- # announcements (1)
- # beginners (21)
- # calva (2)
- # cider (26)
- # clj-kondo (5)
- # cljdoc (4)
- # cljsrn (1)
- # clojure (42)
- # clojure-spec (5)
- # clojure-uk (1)
- # clojurescript (45)
- # cursive (5)
- # data-science (1)
- # datomic (5)
- # emacs (6)
- # fulcro (18)
- # hoplon (8)
- # immutant (1)
- # joker (9)
- # nyc (1)
- # off-topic (72)
- # re-frame (3)
- # reitit (1)
- # rewrite-clj (11)
- # shadow-cljs (9)
- # tools-deps (70)
Hi, I’m trying to fill Fulcro in the bucket of my head… In the tutorial there’s two PersonList
s and each PersonList
have multiple Person
s. There are two PersonList
s 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:
clojure
(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})])]
(div
(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:
clojure
{:other-keys ...
:todos
[{: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
@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.
@clojuriansinvite if you run clj
in your terminal, does that work?
ah right. yeah the clj
and clojure
versions on windows are something powershell related
@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
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: