fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
tony.kay 2020-12-10T01:03:40.270Z

The route params that @holyjak mentioned is how I’d do it. That is not legacy routing. The parameters passed to the routing instruction are made available to will-enter in all targets. They need not be part of the “path”. The path parameters make them part of the decision logic for routing…passing other data just makes them part of the params.

tony.kay 2020-12-10T01:10:38.270200Z

In general I would discourage using :db/id. You end up with a ton of resolvers all saying “I can resolve that given a :db/id”, which gives no specificity to your system. I would highly encourage you to use things like :session/id as UUIDs. This also makes you database easily shardable later and make data migration easier. Technically to-many output should be in vectors, not lists or seqs. Pathom may heal those, but the formal expected data is vectors. https://github.com/realgenekim/fulcro-rad-demo/blob/gene-experiments/src/datomic/com/example/components/database_queries.clj#L119

tony.kay 2020-12-10T01:10:55.270500Z

Your actual query function f a session returns nil:

tony.kay 2020-12-10T01:11:18.271Z

perhaps you meant (log/spy :info session)?

tony.kay 2020-12-10T01:11:34.271200Z

@genekim

genekim 2020-12-10T04:24:02.272200Z

Holy smokes. What a face palm moment! Thanks for catching that, @tony.kay. I fixed the two return value issues you pointed out in the db queries — specifically, the vector shape of get-all-sessions and the stupid nil in get-session-by-eid. But for life of me, I can’t seem to get get-session-by-eid to be called by the resolvers. If I understand correctly, pathom looks at elements of the desired :pc/output, and searches for a set of resolvers to get there… So, somehow, I must be calling parser with the wrong input (`db/id`), or the wrong desired output (`session/title`, etc…) (Sorry, just thinking aloud here…. Checking my changes in, and going to stare at the screen some more! 🙂

genekim 2020-12-10T04:30:57.272400Z

…my goal is to get the resolver working via entity-id first, and then get those uuid properties created…

tony.kay 2020-12-10T04:42:39.272600Z

@genekim did you add it to the list of resolvers?

tony.kay 2020-12-10T04:43:28.273100Z

guessing…not 🙂

tony.kay 2020-12-10T04:43:50.273300Z

the resolvers are installed manually. You can make a macro and atom soln if you want, but by default it is a manual install on server.

tony.kay 2020-12-10T04:43:59.273500Z

see all-attributes and all-resolvers

tony.kay 2020-12-10T04:44:04.273700Z

which compose them all from other nses

genekim 2020-12-10T04:48:32.273900Z

Oh! Okay, looking at how to get it fixed…. Right now, session-by-eid is a pc/resolver , which only shows up in the CLJ portions… Do I convert it to a defattr? (Because I’m guessing the CLJS client needs to see it?) Thanks for your patience and help, @tony.kay!

genekim 2020-12-10T04:49:28.274100Z

(You might see from all my commented out code how many permutations I’ve tried… I already see that I made a defattr version of session-by-eid… Trying that now. 🙂

tony.kay 2020-12-10T18:38:18.283700Z

I’ve fixed the bug in Inspect with network/EQL where quotes were getting lost so that “Send to EQL” was sort of a pain to use. I’m building the chrome store extension now

❤️ 3
tony.kay 2020-12-10T18:42:04.285100Z

Version 3.0.3 of Chrome extension submitted for review.

tony.kay 2020-12-10T18:52:24.285800Z

For those that want to install it early: https://github.com/fulcrologic/fulcro-inspect/releases/tag/chrome-3.0.3

Aleksander Rendtslev 2020-12-10T23:17:08.289Z

I’m sorry if this is something obvious I’ve missed but I’ve been stuck on this for a few hours: I can’t seem to load initial-state in my sub components (defined with defsc). Eg:

(defsc EntryPanel [_ {:user/keys [name]}]
  {:query [:user/name]
   :initial-state {:user/name "Aleksander"}
   :ident (fn [] [:component/id :entry/panel])
   }
  (ui/view {:style (tw :w-full :flex-1 :p-5 :align-start :justify-start)}
           (comp/fragment
             (ui/text {:style (tw :text-sm :mb-1 :text-primary)} "Mon, Nov 17")
             (ui/text {:style (tw :text-2xl :mb-2 :text-primary)} (str  "Good morning, " (.stringify js/JSON params)))
             (ui/text {:style (tw :text-lg :text-primary)} "What did you eat today??")
             (ui-new-entry-overlay))))


(def ui-entry-panel (comp/factory EntryPanel))

// In root:
(defsc Root [_ {:root/keys [random]}]
  {:query [:root/random]
   :initial-state {:root/random "Yo Bro"}}
  (ui/safe-area-view
    {:style (tw :items-center :px-0 :justify-center
                :bg-white :flex-1 :h-full :flex-col)}
    (ui/text
      random)
    (ui-entry-panel {})))
• Nothing shows up in the database in fulcro inspect for EntryPanel (or rather :user/name doesn’t show up) • It’s not in the parameters I’m printing on the screen either • :root/random does work exactly as expected • the initial state dooes show up when I explicitly call (comp/get-initial-state EntryPanel {}) in the repl

tony.kay 2020-12-10T23:24:56.289400Z

has to be composed to root @aleksander990

tony.kay 2020-12-10T23:25:20.289900Z

initial state is about the very first animation frame in the entire program, and is a complete graph from root

tony.kay 2020-12-10T23:25:26.290100Z

it is not a constructor

tony.kay 2020-12-10T23:25:55.290700Z

use mutations and loads to join run-time objects into the view graph. Fulcro uses (by default) a complete reified data graph of the view

tony.kay 2020-12-10T23:26:04.291Z

it is literally View = F(state)

tony.kay 2020-12-10T23:27:27.292100Z

if you want to “hang” a floating root (not connected in data graph) in your UI, you use the multi-root renderer. There’s a demo of that in the workspaces of Fulcro…and I think it’s documented in book. https://github.com/fulcrologic/fulcro/blob/develop/src/workspaces/com/fulcrologic/fulcro/cards/multi_root_cards.cljs

tony.kay 2020-12-10T23:28:33.292600Z

specifically item 2 in https://book.fulcrologic.com/#_adding_initial_state_to_components

Aleksander Rendtslev 2020-12-10T23:29:53.293700Z

Arhh, ok. I think it’s startinng to make sense

Aleksander Rendtslev 2020-12-10T23:30:18.294300Z

So basically this:

(defsc Root [_ {:root/keys [entry-panel]}]
  {:query [:root/entry-panel]
   :initial-state {:root/entry-panel (comp/get-query EntryPanel)}}
  (ui/safe-area-view
    {:style (tw :items-center :px-0 :justify-center
                :bg-white :flex-1 :h-full :flex-col)}
    (ui-entry-panel entry-panel)))

tony.kay 2020-12-10T23:30:25.294500Z

common misunderstanding. I need to write a 3 page “things you MUST know” doc 😜

🙏 1
Aleksander Rendtslev 2020-12-12T20:30:06.336600Z

@tony.kay this was really great. Super nice way to understand the basics. I feel like I have a much better grasp on how everything fits together

tony.kay 2020-12-12T20:31:22.336800Z

I just don’t have a whiteboard right now, or I’d do it over…it’s the right thing for beginners

Aleksander Rendtslev 2020-12-12T20:35:54.337600Z

Absolutely. I had a mental disconnect between the view nodes in the graph and the data that's loaded. It makes a lot of sense to explicitly connect the data to views (as opposed to doing a filter on every render over the entirety of the data). I took a bunch of note that I expect will help future team members

Aleksander Rendtslev 2020-12-12T20:36:25.337800Z

And understanding why I need to go through the root to initiate app state makes a lot more sense now as well

tony.kay 2020-12-10T23:30:46.295200Z

no, get-initial-state

tony.kay 2020-12-10T23:30:48.295400Z

not get-query

Aleksander Rendtslev 2020-12-10T23:30:52.295700Z

arhh of course

Aleksander Rendtslev 2020-12-10T23:30:53.295900Z

my bad

tony.kay 2020-12-10T23:30:55.296Z

you do need to join the query too

tony.kay 2020-12-10T23:31:03.296300Z

and initial-state has magic (it can use query)

tony.kay 2020-12-10T23:32:14.297400Z

i.e. {:root/entry-panel {}} === (fn [params] {:root/entry-panel (get-initial-state EntryPanel {})})

tony.kay 2020-12-10T23:32:33.297800Z

just a shorthand, but super handy…also works in to-many rels

tony.kay 2020-12-10T23:33:28.298600Z

{:root/entry-panel [{:id 1} {:id 2} {:id 3}]} === `(fn [params] {:root/entry-panel [(get-initial-state EntryPanel {:id 1}) (get-initial-state EntryPanel {:id 2} ...]})`

Aleksander Rendtslev 2020-12-10T23:34:00.298700Z

I’m planning on writing a small internal one for new engineers as I bring them on board. So I hope I’ll be able to give something back to this amazing project you’ve built

👍 1
Aleksander Rendtslev 2020-12-10T23:34:47.298900Z

Like this?

(defsc Root [_ {:root/keys [entry-panel]}]
  {:query [:root/entry-panel]
   :initial-state {:root/entry-panel {}}}
  (ui/safe-area-view
    {:style (tw :items-center :px-0 :justify-center
                :bg-white :flex-1 :h-full :flex-col)}
    (ui-entry-panel entry-panel)))

Aleksander Rendtslev 2020-12-10T23:35:14.299100Z

It worked when I did it with get-initial-state explicitly but the “short-hand magic” doesn’t seem to

Aleksander Rendtslev 2020-12-10T23:35:52.299300Z

oh

Aleksander Rendtslev 2020-12-10T23:36:17.299500Z

do I then do this down in EntryPanel

(fn [params] {:root/entry-panel (get-initial-state EntryPanel {})}) 

tony.kay 2020-12-10T23:45:11.299800Z

95% of beginner problems are: didn’t fully grok query/ident/initial-state basics. There’s actually very little to them…it might be helpful to watch this old whiteboard talk I gave on “Untangled”, back when Om Next was still part of the internals. This is probably true for most ppl, I just hate recommending it when it isn’t right for F3, but the GRAPH info and initial state stuff has not changed (though the API and internals are a bit diff): https://www.youtube.com/watch?v=mT4jJHf929Q&list=PLVi9lDx-4C_T_gsmBQ_2gztvk6h_Usw6R&index=8&t=1578s&ab_channel=TonyKay

🙌 5
tony.kay 2020-12-10T23:45:50.300100Z

I really need to redo that video and bring the API and terminology up-to-date…is so very useful I think.

Aleksander Rendtslev 2020-12-10T23:56:01.300700Z

Thank you, by the way. Unblocked and moving forward. This is awesome. And the inspect tool is a game changer