Fork me on GitHub
#fulcro
<
2020-04-28
>
folcon00:04:56

I’m really puzzled by merge/merge-component!, I keep calling it in repl, but nothing seems to be happening… I’ve tried this:

(merge/merge-component! app/SPA ShareListItem msg)
and this:
(merge/merge-component! app/SPA ShareListItem msg :replace [:component/id :share-list :share-list/shares])
The df/load! which works is this:
(df/load! app/SPA :all-shares ShareListItem {:target [:component/id :share-list :share-list/shares]})
So I expected one of them to be similar to the other? But it very much doesn’t appear to be… Figured it out, turns out that for merge-component!, I need to unnest the value:
(merge/merge-component! app/SPA ShareListItem (:all-shares msg) :replace [:component/id :share-list :share-list/shares])

tony.kay16:04:25

Right: Query has to match data input.

folcon19:04:29

I do feel that small things like this really do trip beginners up, I’m trying to document what I can =)… But I’m really aware that I still only have a limited understanding of the system in depth…

mdhaney20:04:19

I would say this is just part of the learning process. When you dig into Fulcro, you get used to working with normalized data and thinking in those terms. Then as you get more comfortable and try more things, you inevitably will need to use merge-component, which requires raw (denormalized) data. It can be a bit disorienting at first, I remember going through something similar when I first started. It goes away quickly. If anything, take it as a sign that you are on the right track with your learning because you are getting used to thinking in terms of normalized data, which is what you should be doing about 90% of the time. So, congrats? 😄

mdhaney20:04:12

BTW, same thing with pre-merge. I think those are the 2 main exceptions to the rule. Oh and initial state.

folcon20:04:13

I get that, but it would be useful to have some of those things being made clearer in stages? So for example, it took me a fair while to work out that I should be passing in :replace, the only other option I know of that can also go there is :append. I don’t know where these are listed, I’ve just seen them used in examples and have tried them… I’m not even sure that’s the total list of options… 😃

tony.kay20:04:14

I’m not sure what you mean by “exception to a rule”. The rule is “the tree of data has to match the query”. ShareListItem has a query, and that map has to have keys for the items in the query. load! builds a query from a keyword and subquery, and the response has to return a tree with that key and sub-tree.

tony.kay20:04:18

There is only “one rule”

tony.kay20:04:45

initial state: Your tree has to match your query…`:x` in the query, :x in the tree

mdhaney20:04:03

Poor choice of words, I guess. My point was that when you first start working with data, i.e. normal mutations mutating app state, you are dealing with normalized data, vs other times when you are dealing with the tree that has to match the query.

Adrian Smith09:04:37

just noticed the fulcro RAD book last night I was blown away by the amount of documentation there

Jakub Holý (HolyJak)13:04:45

I think it is seriously up to date, even the fulcro-rad-demo has troubles keeping up to the changes. I believe Tony wanted to take it down for that reason, people should have a look at the demo and read docstrings while there is so much changes.

folcon14:04:08

Ah, you mean out of date @U0522TWDA?

tony.kay16:04:57

yeah, out of date…anyone familiar with demo might take a shot at updating??? I don’t have the time

tony.kay16:04:38

the bones are right…but the examples are wrong due to a lot of renaming and refactoring cleanup. Most of the core API is stable now, and probably won’t change much. Still Alpha, though

jaide15:04:40

Finally giving fulcro a shot, going through the getting started tutorial now. However, I can't seem to get shadow to build:

npx shadow-cljs server
...
Syntax error (NoSuchFieldError) compiling at (shadow/cljs/devtools/api.clj:1:1)
ES3

thheller15:04:51

@jayzawrotny thats caused by a version conflict, assuming you are using project.clj/deps.edn you probably need to update the cljs version specified there

jaide17:04:56

Also created a PR against the guide to bump the version and explain that. https://github.com/fulcrologic/fulcro-developer-guide/pull/46

thheller18:04:08

well that warning isn't always true. it was just for this version ...

thheller18:04:48

normally things just work but in this case it is the interop from shadow-cljs -> clojurescript -> closure-compiler that all need to align 😛

jaide18:04:13

Ack! Well better to catch that now than later. Will fix.

thheller18:04:52

the issue only exists because of deps.edn too .. if it were just shadow-cljs.edn things would just work 😕

jaide18:04:59

I see, created a new PR to only bump the version then.

jaide15:04:06

Ah thanks! Will fix.