untangled

NEW CHANNEL: #fulcro
curtosis 2016-07-11T01:18:57.002023Z

do components have to have an ident to be able to launch queries (via df/load-field)?

currentoor 2016-07-11T03:48:12.002026Z

also, it kind of makes sense right? a query needs to map to some root in the app state

curtosis 2016-07-11T04:25:19.002027Z

hmm... yeah

curtosis 2016-07-11T04:25:42.002028Z

I got mine working, it's weird with the tab-switching setup

curtosis 2016-07-11T04:30:12.002029Z

I gave my mappings tab an ident of [:ui :mappings]; it doesn't have one because the tab switcher provides ident. When the data comes back, instead of being under {:mappings-tab {1 {:mappings { ... }}} (I haven't updated the tab idents to the new style yet) it naturally ends up at {:ui {:mappings {:mappings { ... }}}}.

curtosis 2016-07-11T04:30:32.002030Z

And yes, there's an extra nesting there I'll have to sort out. 😛

curtosis 2016-07-11T04:32:48.002031Z

I also feel like I'm doing more work than I ought to in the server read to map it to the datomic query. But for the moment it's working, so it's progress.

curtosis 2016-07-11T15:10:24.002033Z

I think I'm still not clear on where data for a tab should be in app-state. The cookbook example uses a link, which is also very helpful, but I'm fuzzy on what happens with a regular query and what the fetch should look like.

2016-07-11T16:11:44.002034Z

are you referring specifically to one of the examples? I don’t think there’s any one correct way to do it

curtosis 2016-07-11T16:16:23.002035Z

this one in particular: https://github.com/untangled-web/untangled-cookbook/tree/master/recipes/tabbed-interface

curtosis 2016-07-11T16:16:47.002037Z

which makes sense to load some data to a top-level key in app-state

curtosis 2016-07-11T16:17:15.002038Z

but when I try to wire up a tab to have its local query work, things go pear-shaped

tony.kay 2016-07-11T16:34:14.002039Z

@curtosis: the example uses a link to get to some dynamically loaded data

tony.kay 2016-07-11T16:34:26.002040Z

otherwise the query is normal, and the app state is graph-natured

tony.kay 2016-07-11T16:35:34.002041Z

A post-mutation could have been used to link (via an ident) to that data in the settings object in the db...and further nested components could have been used if deeper tree structure was desired out of the data (e.g. more normalization)

tony.kay 2016-07-11T16:36:21.002042Z

The query is a union, and that part is what the example is concentrating on. The union itself doesn't affect the deeper structure

tony.kay 2016-07-11T16:38:43.002043Z

So, imagine there are no tabs (e.g. just settings). Make the recursive structure as you would in any other case. Just build the graph. If something is going wrong it has to be one of just a few things: 1. The query is wrong 2. The resulting graph in the database is wrong (e.g. post mutation didn't hook it up correctly) 3. The ident function is wrong (e.g. maybe it didn't normalize properly) 4. Your initial app state isn't composed properly Either 1, 3, or 4 will cause 2...

tony.kay 2016-07-11T16:39:34.002044Z

In general, there really isn't much to it. If the graph is right and the query is written in a way that follows it, then you should see data.

curtosis 2016-07-11T16:44:33.002045Z

I'm not at all convinced my problem is only one of those few things. 😉

curtosis 2016-07-11T16:54:20.002046Z

but that's a helpful way to think about what to look at.

tony.kay 2016-07-11T17:12:24.002047Z

@curtosis: The cool thing about Untangled is that those few items comprise almost everything in the "normal" application pipeline. Unless you're doing some kind of React lifecycle addition or out-of-band processing (e.g. timeout/websocket)...the only other thing I can think of is UI refresh from follow-on reads. It's just a graph database, query, and mutations. Of course, you do have to pick the data apart and pass it through the UI tree...so there are additional silly kinds of mistakes to make. But nothing else in concept since the UI render tree matches the UI query tree.

tony.kay 2016-07-11T17:16:23.002048Z

(which additionally also matches the initial UI state tree)

curtosis 2016-07-11T17:57:49.002049Z

@tony.kay: agreed - that's why I'm using it! and the parts I do understand work superbly. 🙂

tony.kay 2016-07-11T20:39:56.002050Z

@curtosis: Remember that you can run a query on a component, and you can join on an ident. So, you could, at the REPL, hand-write a join on a specific db item's ident to a component's query. Something like: (om/db->tree { [:some :ident] (om/get-query Settings) } db db)

tony.kay 2016-07-11T20:40:30.002051Z

of course, throwing console log statements into each component to watch the data flow is another approach

2016-07-11T22:24:12.002055Z

@currentoor @therabidbanana @jasonjckn have any of you used untangled datomic migrations to convert existing data into a new schema format? we are trying to refactor :category/name as :tag/name. Since :tag/name already exists in our database, we can’t just rename the :category/name attribute as :tag/name. So we have to copy the data from our old categories into new tag entities. Problem is, we don’t have access to the database connection in the migrations file.

2016-07-11T22:25:24.002056Z

Thus far we have been avoiding this issue by saying we're in alpha - old data might be lost. 🙂

2016-07-11T22:25:58.002057Z

I'd love to see some good examples of how to address doing complex transactions in a migration though

2016-07-11T22:26:04.002058Z

yeahh we just passed that point!

2016-07-11T22:26:35.002059Z

ok no worries, i’ll let you know what we come up with. I imagine that we will have to pass the database connection in somehow, otherwise migrations are going to be… interesting

currentoor 2016-07-11T22:36:31.002060Z

I could see that being useful down the road.

tony.kay 2016-07-11T23:14:38.002061Z

we found a good solution. Pretty simple. Ethan's coding it up