untangled

NEW CHANNEL: #fulcro
wilkerlucio 2016-10-03T12:23:51.001585Z

hello, I found myself needing access to the reconciler in a post-mutation, can we make it available there?

grzm 2016-10-03T13:08:53.001589Z

@wilkerlucio you can get at the reconciler through the app atom

grzm 2016-10-03T13:09:57.001591Z

It's also available to any mutation via the env parameter, isn't it?

wilkerlucio 2016-10-03T13:10:26.001593Z

@grzm it's available on the regular mutations, but not on the post mutations, how do you get the reconciler from the app state?

wilkerlucio 2016-10-03T13:11:53.001596Z

in the post mutations it's only sending the state, not the full environment as on the regular mutations

grzm 2016-10-03T13:14:25.001599Z

(:reconciler @app)

grzm 2016-10-03T13:14:34.001600Z

That should do the trick

grzm 2016-10-03T13:16:36.001601Z

That line shows derefing the reconciler to get the app state, but you just need to get the reconciler, right?

wilkerlucio 2016-10-03T13:24:03.001602Z

@grzm thanks for the support, but that doens't work, at the post-mutations you don't have access to the app, only to the state, that's why I'm asking to add the reconciler there, so I can do reconciler operations at the post-mutation

grzm 2016-10-03T13:24:21.001603Z

you've got a global app atom somewhere, don't you?

grzm 2016-10-03T13:24:54.001604Z

I know reaching outside of a function isn't the first choice, but it gets what you need in this case

grzm 2016-10-03T13:25:11.001605Z

I agree that it would be nice to have more available in the env in the mutation

grzm 2016-10-03T13:25:39.001606Z

Perhaps a patch is in order, but there is a solution to your current issue as well šŸ™‚

wilkerlucio 2016-10-03T13:26:07.001608Z

yeah, I'm bringing the discussion to see if there are any points against doing it, I would be happy to submit a patch for it

2016-10-03T14:00:57.001609Z

@wilkerlucio why do you need the reconciler as opposed to the state?

2016-10-03T14:01:18.001610Z

post mutations happen right after the data has been merged from the server, and before rerendering occurs

2016-10-03T14:01:29.001611Z

so having access to the reconciler is potentially dangerous

wilkerlucio 2016-10-03T14:01:59.001612Z

@ethangracer I'm changing a component query into a post-mutation, I wanna wait for the post-mutation to avoid some flickering, but without the reconciler I can't use functions like om/class->any to find my instances

2016-10-03T14:02:36.001613Z

Iā€™m not understanding what you mean by changing a component query into a post-mutation

wilkerlucio 2016-10-03T14:02:47.001614Z

calling om/set-query on a post-mutation

2016-10-03T14:03:12.001615Z

interesting

2016-10-03T14:04:06.001616Z

so, the shortest possible answer would be that we have not been dynamically modifying queries, which is why we havenā€™t had a need for the reconciler

2016-10-03T14:04:20.001617Z

but also, I imagine calling set-query schedules a re-render

2016-10-03T14:04:29.001618Z

which would be bad inside of a post-mutation

wilkerlucio 2016-10-03T14:05:00.001620Z

humm, why triggering a re-render from a post-mutation is bad?

2016-10-03T14:05:10.001621Z

because itā€™s in the middle of a re-render cycle already

2016-10-03T14:05:28.001622Z

it would cause more screen flicker, if it worked

2016-10-03T14:06:29.001623Z

we had several issues with rerendering as we wrote data fetch, to be completely honest Iā€™m not 100% on the technical internals

2016-10-03T14:07:12.001624Z

that would be a question for @tony.kay or someone else on here with a deeper understanding

wilkerlucio 2016-10-03T14:07:17.001625Z

humm, interesting, currently I have an implementation in place, but since I don't have the reconciler I'm using the reference for a component from the ::om/queries in the state, but that's a really bad way of fetching it, it improved my flickering situation, but I believe there might be better ways to archive it

2016-10-03T14:09:34.001626Z

I suspect that post-mutations probably arenā€™t the solution, at least not as we designed them. their only intended purpose is to give you access to the state atom post-fetch and pre-render

2016-10-03T14:10:45.001628Z

for example, if I want to invent some keyword :data that the server recognizes, and sends back some information that I donā€™t have a specific query for on the client

2016-10-03T14:11:01.001629Z

then I can use a post-mutation to pepper that information into the appropriate places in the app state

2016-10-03T14:11:49.001630Z

as for using om/set-query I canā€™t be much help because I havenā€™t used it šŸ˜•

wilkerlucio 2016-10-03T14:12:26.001631Z

umhum, just to get you more context, what happens in my case is that I use a dynamic query for routing

wilkerlucio 2016-10-03T14:12:49.001632Z

so, on a first step I have to get a new page query and trigger a server load

wilkerlucio 2016-10-03T14:13:09.001633Z

if I change the query at this stage, I'll have a new query and in place, but no data for it (still fetching)

wilkerlucio 2016-10-03T14:13:27.001634Z

so it loads the page without data, and that's a state that I don't want

wilkerlucio 2016-10-03T14:13:47.001635Z

so I was delaying the set-query to after the data was fetched

2016-10-03T14:14:39.001636Z

what about calling om/set-query and then immediately calling data fetch? you could use the loading marker at :ui/loading-data to render a loading UI while you wait for the fetch

2016-10-03T14:14:49.001637Z

instead of just a blank screen

2016-10-03T14:15:28.001638Z

or do you want it to load in the background?

wilkerlucio 2016-10-03T14:15:31.001639Z

that's a possibility, my current would be to don't replace the current screen until we have more data, it's not super important but it's a detail that I would like to be able to archive

wilkerlucio 2016-10-03T14:15:39.001640Z

yeah, background loading

2016-10-03T14:16:11.001641Z

thatā€™s an interesting use case which Iā€™m not sure weā€™ve thought about in that way

wilkerlucio 2016-10-03T14:16:12.001642Z

I just have one of those youtube-like thin loading bar at the top

wilkerlucio 2016-10-03T14:16:34.001643Z

I use the load markers to drive the loading bar, they are quite useful there

2016-10-03T14:16:52.001644Z

awesome, yeah that makes sense

2016-10-03T14:19:12.001645Z

fwiw, I think the way Iā€™d try to approach something like that was by using routing with union queries and using the post-mutation to change the ident once the data fetch has completed. So that way, the UI doesnā€™t change until the data has returned from the server. not sure how well itā€™d work, but itā€™s another approach.

2016-10-03T14:20:15.001646Z

but I think your use case is a reasonable one if youā€™re not using union queries, in which case Iā€™d be curious to hear thoughts from others on the untangled team once theyā€™re online (probably another couple hours)

2016-10-03T14:20:35.001647Z

I feel like weā€™ve talked about background loading before but I canā€™t remember the context

wilkerlucio 2016-10-03T14:23:07.001648Z

umhum, I though about union queries at a point, but I'm building something that goes more into a website-like page, which means I have lot's of pages, the union query would be quite big and would keeping getting bigger, so dynamic queries sounded a better approach here

wilkerlucio 2016-10-03T14:26:50.001649Z

and I'm also curious about the other untangled core team thoughts are on this šŸ™‚

gardnervickers 2016-10-03T14:44:30.001651Z

I think the point of using a union query is that youā€™re able to change the active ā€œbranchā€ of the union query, allowing you to only query for a subset of the entire thing.

wilkerlucio 2016-10-03T14:51:39.001652Z

yes, union queries are great, specially when you have a predictable number of variations, I see the union queries more like for heterogeneous lists, when you are likely to use multiple of the branches at once, but for website routing I think it's a bit off, because you would always be sending the queries for all the pages (a number that can be quite large for a big site) only to actually fetch the data for one of then

2016-10-03T15:01:41.001653Z

not necessarily. you could just load the first page. then when you prepare to switch the ident, load the second page. etc. you certainly can load everything at once if you send the entire root query to server on app load, but you donā€™t have to

gardnervickers 2016-10-03T15:03:43.001654Z

For example, we have a union query right below our root component to implement tabbed browsing. We just run data loads from each of the components in that union.

wilkerlucio 2016-10-03T15:08:06.001655Z

humm, you mean when you change a tab, you filter from the union query to ask for the server for that branch only?

2016-10-03T16:03:34.001656Z

@wilkerlucio yes exactly

2016-10-03T18:49:05.001659Z

PSA: the untangled team and @mitchelkuijpers are doing an untangled documentation write-a-thon this week. our plan is to make it easier to find the documentation that does exist, as well as fill out missing areas include our READMEs, reference guide, tutorial, and design conventions (mutation philosophy, data load philosophy, error handling, etc.). If anyone has thoughts on areas that could use documentation, we are open to suggestions.

2016-10-03T19:55:03.001660Z

Also, testimonials for the website would be greatly appreciated if anyone is willing? @jasonjckn @kenbier @currentoor @therabidbanana @wilkerlucio @gardnervickers @grzm

šŸ‘ 3
grzm 2016-10-03T19:56:12.001661Z

@ethangracer sure. I'll write one up.

currentoor 2016-10-03T19:59:01.001662Z

@ethangracer of course! Should I just direct message it to you?

2016-10-03T20:00:55.001663Z

@ethangracer sure! adstage could add one, its been great for us

2016-10-03T20:01:55.001664Z

@currentoor @grzm thank you! yeah a DM to me works. If we could post company logos that would be helpful too ā€” we want people to know that real companies are using this tool for code in production. No worries if we canā€™t, but if we can thatā€™d be great!

grzm 2016-10-03T21:15:45.001667Z

ok: what I want to do: test mutations that reference env ref, so I'll need to be able to run transact with the appropriate component, correct? Which means I'll need to instantiate the app, right? And mount it?

tony.kay 2016-10-03T21:16:23.001669Z

Why don't you test the mutation by running it directly?

tony.kay 2016-10-03T21:16:31.001670Z

why make it an integration test?

tony.kay 2016-10-03T21:16:45.001671Z

pass it some made-up state in the env

grzm 2016-10-03T21:17:00.001672Z

That's why I'm asking, cause I'm currently thinking this through.

tony.kay 2016-10-03T21:17:15.001673Z

Yeah, avoid integration tests...they are slow/heavy/fragile

tony.kay 2016-10-03T21:17:23.001674Z

prove that your mutation works as a pure function

grzm 2016-10-03T21:17:44.001675Z

That makes sense.

tony.kay 2016-10-03T21:17:44.001676Z

make a minimal mock db in state, put the ref and state in env, then show it results in correct post state

tony.kay 2016-10-03T21:17:58.001677Z

Our protocol testing support can help with that, but it is undocumented

tony.kay 2016-10-03T21:18:03.001678Z

(correcting that this week, I hope)

2016-10-03T21:18:20.001679Z

((:action (m/mutate {:state (atom {:test :state}} :ref [:expected :ident]} ā€™some/mutation {:params :list})))

grzm 2016-10-03T21:18:26.001680Z

Thanks for the sounding board, guys

tony.kay 2016-10-03T21:18:32.001681Z

yep

wilkerlucio 2016-10-03T21:38:02.001682Z

@tony.kay hey, if you have some time, can you please give me your thoughts on the idea of using the reconciler on post-mutations? (regarding the discussion early here) would your consider making the reconciler available there?

tony.kay 2016-10-03T21:43:40.001683Z

no I would not suggest doing that

tony.kay 2016-10-03T21:43:49.001684Z

use-case?

tony.kay 2016-10-03T21:45:26.001689Z

@wilkerlucio what is your use-case?

wilkerlucio 2016-10-03T21:47:05.001690Z

I'm doing routing with dynamic queries, I fire the query for that page to load, and in the post-mutation I change the parent query (after the data has come in), I need the reconciler so I can access the indexer (making easier to find the element to set-query on)

2016-10-03T21:47:06.001691Z

did anyone save tonyā€™s "blog postā€ in the channel about the reasoning behind server mutations never returning data, and following up with server loads instead? @therabidbanana @mitchelkuijpers I seem to remember you both chatting about it

wilkerlucio 2016-10-03T21:47:41.001693Z

@tony.kay ^^, or for the long version: https://clojurians.slack.com/archives/untangled/p1475503257001609

2016-10-03T21:49:03.001695Z

@ethangracer by "blog post" do you mean the exact text of the message, or just the subject I found interesting and worth writing out in the message?

2016-10-03T21:49:26.001696Z

the exact text šŸ˜¬

2016-10-03T21:49:31.001697Z

I realize itā€™s a long-shot ask

2016-10-03T21:49:53.001698Z

slack just erased it

anmonteiro 2016-10-03T21:50:17.001700Z

have fun

2016-10-03T21:50:28.001701Z

Oh, looks like it's just beyond the threshold of time for Slack

tony.kay 2016-10-03T21:51:09.001702Z

@anmonteiro Sweet...didn't know about that nugget

2016-10-03T21:51:29.001703Z

@anmonteiro šŸ˜†

2016-10-03T21:51:32.001704Z

thank you

tony.kay 2016-10-03T21:51:37.001705Z

there go them darn programmers making things better (also known as working around product paywalls)

2016-10-03T21:51:48.001706Z

https://clojurians-log.clojureverse.org/untangled/2016-09-27.html <- it's on this day specifically

2016-10-03T21:52:45.001710Z

thanks everyone!