untangled

NEW CHANNEL: #fulcro
2017-03-14T11:11:56.228820Z

Hi, I just finished first-mutation video tutorial. I have a question. I still don't understand why on method m/mutate 'app/add-item, we have to manually integrate ident. For example calling (uc/integrate-ident! state iatem-ident :append list-path). But on MyList don't, for example only calling (uc/initial-state Item {:label "A"}) and ident already there.

urbank 2017-03-14T11:28:28.418404Z

@codxse Take my explanation with a grain of salt. InitialAppState is meant to get an initial structure for the data, and establish the tables. So things declared in InitialState get normalized automatically at app start-up.

urbank 2017-03-14T11:29:42.432130Z

this doesn't happen at every mutation (not automatically)

2017-03-14T11:31:33.453735Z

@urbank do you mean when we call (om/factory MyItem) ?

urbank 2017-03-14T11:35:06.494085Z

@codxse Hm... I don't think so. A component doesn't need to be rendered to participate in the initial normalization. It just needs to be in InitialAppState and IQuery, as well as have an Ident (I may be wrong, though, I'm quite new)

2017-03-14T11:35:54.502958Z

Ok, no problem. I get it πŸ˜‰

urbank 2017-03-14T11:37:15.517253Z

@codxse Someone's probably going to come online who's better at explaining this. In the meantime, have you seen this video by Tony Kay?

urbank 2017-03-14T11:37:16.517424Z

https://youtu.be/mT4jJHf929Q

2017-03-14T11:38:08.527435Z

Ok, let me see.

urbank 2017-03-14T11:46:55.624940Z

@codxse Also, merge-state! described here might be useful to you (though I haven't yet used it)

2017-03-14T11:50:08.660945Z

great, it will be helping

wilkerlucio 2017-03-14T17:07:44.339502Z

@codxse when you app starts the state, it uses the query (and it's metadata) to normalize your database, during the normalization process the indexes are going to be created and the previous initial data will be converted into idents, but that only happens on the initialization, where you data is denormalized, after that you are responsible to keep it normalized, that's why you need to do that on the mutation. makes sense?

πŸ‘ 1
tony.kay 2017-03-14T17:31:23.893131Z

with one refinement: server responses (or any tree-based novelty with a query run through (om/merge! reconciler tree-of-data query-for-tree-of-data ) are auto-normalized.

πŸ‘ 1
tony.kay 2017-03-14T17:31:45.901969Z

Untangled's merge-state! is similar (but it let's you give a component for the query)

tony.kay 2017-03-14T17:33:31.944305Z

Mutations are the abstractions over generalized database (and their remote counterpart) operations...most commonly editing a few props on already normalized data, followed by optional tweaks to graph edges)

wilkerlucio 2017-03-14T17:43:49.185405Z

interesting, I didn't knew the normalization also happened on merge, cool stuff πŸ™‚

2017-03-14T17:53:30.410929Z

cool! it make more clear to me. :))

gardnervickers 2017-03-14T23:37:34.574881Z

@tony.kay When doing a df/load on a component with :ui/* keys in the query and in the entity, they should remain untouched right?

tony.kay 2017-03-14T23:38:09.580393Z

So, @adambros found a bug when loading by ident that would mess that up

tony.kay 2017-03-14T23:38:23.582756Z

but yes, that is how it should work

tony.kay 2017-03-14T23:38:33.584558Z

I am guessing you're doing that πŸ˜•

tony.kay 2017-03-14T23:40:03.599876Z

the merge story in Untangled is one of the most complicated bits of logic, actually, because of our desire to make that happen correctly in a number of cases

gardnervickers 2017-03-14T23:40:51.607589Z

Yup, but it’s a problem we’ve been able to avoid. I was just wondering what it should be so if we do hit another issue with it I can investigate. Thanks!

tony.kay 2017-03-14T23:41:52.617230Z

The "should" is: 1. If you asked for it and didn't get it, it gets removed 2. If you didn't ask for it, and you already had it, it is kept 3. Since :ui/??? are not part of what you "ask the server for", they should fall into (2)

gardnervickers 2017-03-14T23:43:15.630600Z

Gotcha, makes sense!

tony.kay 2017-03-14T23:46:21.659918Z

Added as issue #69 on U.C.