Fork me on GitHub
#fulcro
<
2019-04-17
>
danielstockton12:04:38

Am i right to think that there is never a reason for a component to have an ident if it doesn't also have a query?

claudiu12:04:06

yep 🙂 if no ident and query it could just be a normal defn unless you need react stuff there like life-cycle.

tony.kay13:04:46

True, but Remember that defsc gets you pure component optimization which can be better than just defn

8
danielstockton14:04:33

Specifically, I was considering the case of passing an ident to re-read after transact, and if that component had an ident but not a query. I came to the conclusion that it probably never even makes it into the indexer if the query isn't pulled up into root, so the re-read is probably a no-op?

tony.kay14:04:20

you still in Om Next land?

danielstockton14:04:44

Or if it could somehow identify the component from the ident, it traverses up the tree to find the closest ancestor with a query, and re-reads/renders from there. But i couldn't see how that would be implemented.

danielstockton14:04:16

I'm in om.next land, but I'm guessing the principles are similar, or if not, interested how they might be different.

tony.kay14:04:36

In Om Next ident-based targeted refresh isn’t as “optimal” as you might think…it is just used to find the component. The query still has to run from root unless you enable the ident render optimization.

tony.kay14:04:49

and then your parser has to be written to support that

tony.kay14:04:39

in terms of what Om Next’s rendering does: It can “focus” the query only if a component has a query (trim away side branches that don’t need refresh)

tony.kay14:04:57

I think your indexes would be inconsistent…don’t think it was ever an intended use-case…but the parser does add metadata at every level of props about how it “arrived” at a given component. I think the props you’d pass to such a component would be missing that info (since there was no query to traverse)

tony.kay14:04:15

so “figuring out” how to step up to a parent would not be possible

tony.kay14:04:38

In Fulcro, targeted refresh only ever happens if your component has a query and ident.

tony.kay14:04:06

because that (to me) is really the only case that makes sense in the larger context of the vast majority real apps

tony.kay14:04:46

when you look at the actual performance numbers, though, the real cost that isn’t ideal is in things like focusing the query, adding path data to the parser result, etc. My experiments for (upcoming) Fulcro 3 show that it is better to eliminate those overheads in preference for a simpler overall algorithm (which Om Next can’t support, because of the requirement of the parser)

tony.kay14:04:34

primarily because Fulcro has the opinion that the client-side parser is a complex artifact whose benefits are far outweighed by the engineering difficulties it adds…unless you do what Fulcro did: just have it call db->tree.

tony.kay14:04:23

and at that point, having the parser in the mix just further complicates the full-stack story as well

tony.kay14:04:12

You should make sure you’ve read this: https://fulcro.fulcrologic.com/vsom-next.html

danielstockton14:04:37

Interesting, I think I assumed query focusing was standard in om. I imagined it starting from the component with the key to be re-read and taking a slice of the query all the way back to root, and only running that.

danielstockton14:04:54

But I'm sure you're right, the complexity of that probably adds more overhead than its worth

tony.kay14:04:18

it does take a slice back to root

tony.kay14:04:51

but if you have an ident on the component, and only use db->tree, then it is trivial to already know the query you need (in isolation)

tony.kay14:04:06

[{ident-of-component query-of-component}]

tony.kay14:04:42

so no query focus, no path meta (which is more expensive than db->tree), no parser (which does multiple passes), etc.

tony.kay14:04:03

you can make the whole mess many times faster (and less confusing internally and externally)

danielstockton14:04:58

Have trouble groking that, because components with idents are usually nested and their query is not the whole query, its a partial query

danielstockton14:04:24

Don't you need the slice back to root, to know where to start reading?

tony.kay14:04:58

the ident is the place to start reading if your db is normalized

danielstockton14:04:04

i.e. you know part of the query, but you still have to work your way back to the full query

danielstockton14:04:12

Aah, yes, right

tony.kay14:04:17

that’s where you’ll always be no matter what query you followed to get there

danielstockton14:04:27

Yes, obvious now

tony.kay14:04:43

unless you’re using a parser that can “mess with that”…like adding context to env as it goes

tony.kay14:04:02

which is why Om Next can’t turn that on by default

tony.kay14:04:05

but Fulcro can

tony.kay14:04:52

lots of really nice things fall out when you drop the parser on the client…and you lose nothing that doesn’t have another (cleaner) way of doing it

tony.kay14:04:18

95% gains….5% losses

tony.kay14:04:27

which is why Fulcro exists 🙂

tony.kay14:04:43

Fulcro 2 doesn’t have Om Next as a dep anymore but it has a lot of the internals. Fulcro 3 will have very very little original Om Next code in it. Fulcro’s internals are more complex than they need to be bending over backwards to use Om Next arch

danielstockton14:04:44

Yep, i've followed fulcro's development from a distance (know that it dropped om next). By dropping the parser on the client, do you mean providing a stricter api for reading/mutating state? That's how I understand it

danielstockton14:04:56

Presumably there is something similar to a parser underneath, but you're able to control how it's used

tony.kay14:04:04

so, all mutations are is a way of turning a bit of data into a list of operations…you don’t need (much) parsing to deal with that..simple AST conversion and reduce is all.

tony.kay14:04:52

for reads: db->tree is really sufficient. Loads really should not be part of the parser IMO, as described in that doc, and other things I’ve published

danielstockton14:04:18

Let me read that page on the differences, because i think it may clear up a few things

tony.kay14:04:33

what do you need to do a load via the parser? You need a mutation. Because otherwise you haven’t “remembered” what you queued to load and if another parser run happens you’ll queue the load again.

tony.kay14:04:06

I mean, you can swap on state as you “parse”…it’s just all convoluted

tony.kay14:04:41

then you’ve got the root trimming madness, etc…it’s all really very overly complicated

tony.kay14:04:23

the parser (as a way to hydrate UI) gives you nearly nothing at very great cost in all practical cases I’ve found. Sure you can come up with theoretical benefits, but I care about getting stuff done

danielstockton14:04:58

Yep, sounds like it resonates with my experience

danielstockton14:04:30

I usually find a way to get stuff done in om.next, but sometimes it isn't pretty

currentoor16:04:55

@U0DHDNZR9 ^ that was exactly my experience until i started using fulcro

currentoor16:04:43

AFAIK om next was never actually used by it’s author(s) in an actual application

currentoor16:04:44

it has a lot of really good ideas, that fulcro adopted, but also has a bunch of rough edges and was never completely finished