untangled

NEW CHANNEL: #fulcro
mitchelkuijpers 2017-04-05T10:10:43.007463Z

@tony.kay All of our problems seem to be fixed awesome

mitchelkuijpers 2017-04-05T10:11:53.022002Z

I don't think we have a custom network handler we do simply use make-untangled-network And then we add a request-transform option to add our JWT token

urbank 2017-04-05T11:04:33.636877Z

So I think these two diagram illustrate what I'm trying to deal with at the moment. I don't have a View of data and a corresponding Form for editing a single item of the data, but rather the Views ARE Forms... they display phone numbers and they also enable editing them.

urbank 2017-04-05T11:06:57.664048Z

In this case, whenever I edit something in PhoneListA, I need to update PhoneListB

gardnervickers 2017-04-05T11:36:45.995002Z

@urbank In some places where we have multiple lists that should always contain the same idents, we normalize the list as something like [:phone/list :all].

gardnervickers 2017-04-05T11:37:18.000957Z

Where PhoneList then has the ident [:phone/list :all].

gardnervickers 2017-04-05T11:38:34.015232Z

:phone/list is then a table in the app-db, with it’s value being a list of idents for [:phone-number/by-id …] or something.

gardnervickers 2017-04-05T11:39:45.028782Z

Normalization is the right answer for updating app-state once and having it reflect throughout your UI tree.

urbank 2017-04-05T11:53:56.193685Z

@gardnervickers Hm, right. This actually solves a good part of it! Something's still bothering me, but I'm not very sure about the specifics yet.

tony.kay 2017-04-05T15:24:49.329375Z

@mitchelkuijpers Cool. Thanks for the verification. I'll probably cut that as a release now that we have the kinks worked out.

mitchelkuijpers 2017-04-05T15:26:00.358060Z

That would be awesome, only thing I noticed is that I have tot set the refresh for idents when using loads

tony.kay 2017-04-05T15:26:10.361849Z

?

tony.kay 2017-04-05T15:26:43.375441Z

you mean loading by ident doesn't cause a refresh of those UI items?

mitchelkuijpers 2017-04-05T15:26:49.377555Z

So I have to give load the refresh param when doing a load on a ident

tony.kay 2017-04-05T15:27:06.384642Z

hm. strange. I would have thought Om would have gotten that

mitchelkuijpers 2017-04-05T15:27:14.387530Z

Yes, sorry I am on my mobile phone

tony.kay 2017-04-05T15:27:40.398477Z

is this when you load using the reconciler, I'd guess?

mitchelkuijpers 2017-04-05T15:28:02.407367Z

Hold on getting my laptop

mitchelkuijpers 2017-04-05T15:30:51.477426Z

When i do

(df/load this [:foo/by-id 1] MyComponent)

tony.kay 2017-04-05T15:31:00.481207Z

what is this?

mitchelkuijpers 2017-04-05T15:31:13.486380Z

A component without a query

mitchelkuijpers 2017-04-05T15:31:21.489959Z

So I guess that is the same as just the reconciler

tony.kay 2017-04-05T15:31:45.499659Z

um...it can't work if this isn't a stateful component or the reconciler

mitchelkuijpers 2017-04-05T15:32:09.508566Z

this is a component

tony.kay 2017-04-05T15:32:11.509345Z

I guess it could if it is at least an Om component

mitchelkuijpers 2017-04-05T15:32:15.511129Z

Yes

tony.kay 2017-04-05T15:32:16.511301Z

but stateless...

mitchelkuijpers 2017-04-05T15:32:44.523083Z

it is just a

(defui Object (render [this] ...)

tony.kay 2017-04-05T15:33:26.540439Z

got it. and we removed the global forced rerender, which is why it changed

mitchelkuijpers 2017-04-05T15:33:47.548800Z

Yeah, but I would expect to at least trigger a rerender by ident when you are loading by ident

mitchelkuijpers 2017-04-05T15:33:53.551130Z

But maybe that is a wrong assumption

mitchelkuijpers 2017-04-05T15:34:31.566532Z

(df/load this [:sale.issue/by-id issue-link-id] LinkedIssue {:refresh [[:sale.issue/by-id issue-link-id]]})

mitchelkuijpers 2017-04-05T15:34:34.568035Z

this feels wrong

tony.kay 2017-04-05T15:35:30.590564Z

I had assumed that as well. I thought Om queued the queried stuff, but obviously it doesn't. The model does typically assume you trigger transactions from the thing that is the parent of the stuff that needs to re-render, and you add follow-on reads for the stuff not in that subtree

tony.kay 2017-04-05T15:35:39.594361Z

so, this was probably my misunderstanding

tony.kay 2017-04-05T15:35:53.600205Z

I'll set up the loads by ident to auto-add the ident to the refresh list

mitchelkuijpers 2017-04-05T15:36:48.622185Z

That would be awesome, would it be logical to do the same when you specify a target for the load? Or load for example :foo/list

tony.kay 2017-04-05T15:37:15.632140Z

possibly

tony.kay 2017-04-05T15:37:30.638604Z

the problem is people can do non-normalized things

tony.kay 2017-04-05T15:37:38.641353Z

so target might target some tree in the db

mitchelkuijpers 2017-04-05T15:37:42.642986Z

I would think that that is a good default unless a refresh prop is given

mitchelkuijpers 2017-04-05T15:37:52.647356Z

Ah yeah that would be a problem

mitchelkuijpers 2017-04-05T15:38:14.655463Z

(they should not do that btw) 😛

mitchelkuijpers 2017-04-05T15:38:27.660848Z

But that is a good case where you don't want it

tony.kay 2017-04-05T15:38:48.669305Z

It wouldn't hurt anything to add an ident made of the first two components of the target to the refresh list. Just might not do anything. I don't think Om would puke on it...I'll have to try

tony.kay 2017-04-05T15:39:58.696650Z

1. kw w/no target -> add load kw to refresh list 2. ident -> add ident to refresh list 3. target has 2+ elements -> add first two components of target as ident in refresh list

tony.kay 2017-04-05T15:40:56.719850Z

I'll code that up and push a snapshot in a bit

mitchelkuijpers 2017-04-05T15:41:38.736629Z

Nice that sounds like good defaults

tony.kay 2017-04-05T16:11:55.444626Z

@adambros bug in U.spec: It adds selectors to URIs in devcards for some reason in projects that use it. Some kind of hook is getting installed that should not be

tony.kay 2017-04-05T16:12:11.450083Z

on hot code reload

tony.kay 2017-04-05T16:14:46.505858Z

transact is running on set-active-selectors

tony.kay 2017-04-05T16:38:42.016877Z

@mitchelkuijpers new snapshot is on clojars. It is really well-tested, so I may just push a release.

mitchelkuijpers 2017-04-05T16:44:42.140881Z

Awesome will test it out tomorrow

gardnervickers 2017-04-05T16:52:08.297883Z

Hey folks! While there is a tx/fallback for a server mutation causing an error, is there an equivalent for a successful server mutation? I know that kinda goes against the grain of optimistic updates, but the only thing I can think of would be attaching my successful mutation handler to the :post-mutation handler of a transaction that loaded the resource again.

tony.kay 2017-04-05T16:52:26.304376Z

yes

tony.kay 2017-04-05T16:53:32.327061Z

there is a :mutation-merge option on client

tony.kay 2017-04-05T16:54:19.343631Z

it can transform app state. cannot trigger more remoting, but otherwise should work

tony.kay 2017-04-05T16:55:21.364982Z

set it up, for example, with a multimethod that dispatches on the second arg (the mutation sym)

tony.kay 2017-04-05T16:55:41.372194Z

then you can put your post-mutation handling next to your regular mutation handlingon the client

tony.kay 2017-04-05T16:57:40.414579Z

if what you want it remoting, then you're better off composing a remote-follow-on read into the tx itself (e.g. (transact! this ` [(mutation) (untangled/load ~params)])

tony.kay 2017-04-05T16:58:05.423537Z

argh,...quoting

gardnervickers 2017-04-05T17:03:13.534983Z

Ah interesting thank you.

tony.kay 2017-04-05T17:13:54.756698Z

Untangled Client 0.8.1 released to clojars. Fixes some load marker issues, adds support for parallel networking (used by file upload stuff in untangled-ui), removes hard dep on devcards.

tony.kay 2017-04-05T17:17:38.834206Z

@emilyseibert Hey Emily! Glad to see you!

emilyseibert 2017-04-05T17:19:54.881636Z

hey! working on ramping up on untangled this evening. super excited to show it off to WillowTree!

tony.kay 2017-04-05T17:20:54.902006Z

Sweet. Let me know if you need any help. The getting started youtube videos are possibly easiest for getting your hands dirty. Then there's a whiteboard video as well on loading data and such.

tony.kay 2017-04-05T17:23:25.954297Z

Some of the stuff, like adding server components video, has better options now if you need to customize the server. The in-the-large videos also led to API expansion in the lib, just FYI (e.g. UI routing is now in devguide)

tony.kay 2017-04-05T17:24:08.968868Z

it was good talking to you at clj-west. Thanks for dropping by!

gardnervickers 2017-04-05T18:01:45.779977Z

@tony.kay Should server exceptions on mutations be causing a Root re-render?

tony.kay 2017-04-05T18:04:08.833248Z

um. should, or is it programmed to ?

tony.kay 2017-04-05T18:04:13.834916Z

😉

tony.kay 2017-04-05T18:04:35.843426Z

I am guessing it will only re-render what the mutation would have re-rendered.

tony.kay 2017-04-05T18:04:47.847713Z

but, now that you mention it, it might be a good idea

gardnervickers 2017-04-05T18:05:13.857327Z

Heh I wasn’t sure if there was a reason that a mutation down in the tree that failed on the server caused the entire app to re-render from Root

gardnervickers 2017-04-05T18:05:29.863213Z

Even if we’re not catching it with tx/fallback

tony.kay 2017-04-05T18:06:59.895650Z

I'd have to look at the fallback logic...don't have it memorized

gardnervickers 2017-04-05T18:08:16.923812Z

No worries, thanks!

gardnervickers 2017-04-05T18:08:22.926511Z

I can hunt it down

tony.kay 2017-04-05T18:08:59.939875Z

They run outside of the transaction system (since they're in the network layer)

tony.kay 2017-04-05T18:09:20.947231Z

impl.data-fetch

tony.kay 2017-04-05T18:10:12.965652Z

Could augment https://github.com/untangled-web/untangled-client/blob/develop/src/untangled/client/impl/data_fetch.cljc#L466 with an or to get what you want

tony.kay 2017-04-05T18:10:38.975625Z

in fact, that should have been there...we even have an atom for tracking it 😕

tony.kay 2017-04-05T18:12:23.013265Z

yeah, which it was in commit 37db9fca55a11a30f

gardnervickers 2017-04-05T18:12:25.013882Z

I think our issue is with items here https://github.com/untangled-web/untangled-client/blob/develop/src/untangled/client/impl/data_fetch.cljc#L445

tony.kay 2017-04-05T18:12:40.019169Z

got lost in an optimization

tony.kay 2017-04-05T18:13:13.030681Z

no, that line looks fine to me. Refresh everything you've asked refresh

tony.kay 2017-04-05T18:13:22.034079Z

that is the correct happy path behavior

tony.kay 2017-04-05T18:14:04.049630Z

oh wait. that is ran-mutations, not fallbacks

tony.kay 2017-04-05T18:15:13.073560Z

nvm...I was looking at loaded, not error

tony.kay 2017-04-05T18:15:35.082121Z

@ran-fallbacks just needs to be in the root rerender logic

tony.kay 2017-04-05T18:17:14.116964Z

@gardnervickers Fixed. On 0.8.2-SNAPSHOT on clojars

tony.kay 2017-04-05T18:17:24.120733Z

oh wait...upload failed...

tony.kay 2017-04-05T18:17:59.133241Z

ok...it is there now

gardnervickers 2017-04-05T18:21:29.207714Z

Cool, so that will stop force rendering from root on fallbacks?

tony.kay 2017-04-05T18:21:49.214898Z

oh, no...that will MAKE it force root re-render if there is a fallback on error

gardnervickers 2017-04-05T18:21:51.215590Z

Or server error I should say

tony.kay 2017-04-05T18:22:31.229801Z

I mean, we could argue that an error should always force a root re-render, since the fallback could have modified anything anywhere to deal with the error

tony.kay 2017-04-05T18:28:14.353109Z

what say you?

tony.kay 2017-04-05T18:29:06.372138Z

fallbacks only run on server errors. They can do whatever they like to app state. They happen infrequently. As I think about it, I think root re-render is better in all cases

michaeldrogalis 2017-04-05T18:29:19.376776Z

@tony.kay We’re in a situation where we’re creating an entity inside a modal, and the server is rejecting the write. This is causing the page to remount, and the modal flickers.

tony.kay 2017-04-05T18:29:49.387879Z

shouldn't flicker...DOM diff should do nothing if it didn't change

tony.kay 2017-04-05T18:30:07.394539Z

unless you already dismissed it (refresh would hide it) and re-show it on error.

michaeldrogalis 2017-04-05T18:30:36.405717Z

Yeah, I’m not sure what’s up. We’re not changing anything in the DOM there. Trying to hunt it down.

tony.kay 2017-04-05T18:30:37.406215Z

oh...I guess the react key change could possibly cause that

tony.kay 2017-04-05T18:30:57.413275Z

forced root render leads to root render, which changes the react key, which rewrites the entire DOM

michaeldrogalis 2017-04-05T18:31:19.421464Z

Yeah.

tony.kay 2017-04-05T18:31:26.423683Z

but that is a dev-mode concern (the key change).

tony.kay 2017-04-05T18:31:47.431441Z

I think you want the root re-render, but not the key change

michaeldrogalis 2017-04-05T18:32:00.436337Z

I’m not sure if that’s the root cause here. I’ll let you know.

tony.kay 2017-04-05T18:32:59.457571Z

take react-key off of root

michaeldrogalis 2017-04-05T18:34:25.488719Z

@tony.kay You got it

michaeldrogalis 2017-04-05T18:34:45.495728Z

Why does the key change in dev mode? I wasn’t aware of that behavior.

tony.kay 2017-04-05T18:35:06.503421Z

so that if you hot code reloaded a UI change, but the state didn't change, then Om would optimize away the re-render

tony.kay 2017-04-05T18:35:19.507506Z

the :key on root is for that, and ONLY that

michaeldrogalis 2017-04-05T18:35:26.510676Z

Ahh, that makes sense. Thanks for helping me track that down.

tony.kay 2017-04-05T18:35:27.511173Z

you don't want/need it in production

tony.kay 2017-04-05T18:35:48.518627Z

you might even have a ProductionRoot and DevRoot

tony.kay 2017-04-05T18:36:09.525900Z

Then your production mount in main.cljs could be diff than dev mount in user.cljs for example

michaeldrogalis 2017-04-05T18:36:30.533701Z

@tony.kay That’s sensible. Thank you 🙂

tony.kay 2017-04-05T18:37:32.555716Z

welcome

tony.kay 2017-04-05T20:04:24.319944Z

@michaeldrogalis @gardnervickers 0.8.2-SNAPSHOT. I changed it to always rerender from root, but NOT change the react key

tony.kay 2017-04-05T20:05:07.333815Z

so that should eliminate the flicker without needing to worry about the react-key

tony.kay 2017-04-05T20:05:51.348471Z

both of those callbacks essentially should be avoiding touching the react key. If no data changed, nothing should re-render...and Om already handles that

tony.kay 2017-04-05T20:06:06.353664Z

on clojars

michaeldrogalis 2017-04-05T20:09:57.428427Z

@tony.kay Cool, thank you!

tony.kay 2017-04-05T20:10:13.433325Z

I'll make a similar change for loading as well

tony.kay 2017-04-05T20:10:18.435124Z

happy path

tony.kay 2017-04-05T20:12:23.475712Z

pushed that just now...so neither should flicker