untangled

NEW CHANNEL: #fulcro
tony.kay 2016-10-07T00:36:41.002001Z

@jasonjckn That API is not anywhere near final. It is going to evolve. I would not base things on it yet.

2016-10-07T00:36:56.002002Z

gotcha

mitchelkuijpers 2016-10-07T12:30:58.002009Z

Is there any way to know when a remote mutate is done? something like :post-mutation for a mutation

mitchelkuijpers 2016-10-07T12:31:21.002010Z

I thought that was the multimethod post-mutate but I was obviously wrong

2016-10-07T12:58:59.002011Z

@mitchelkuijpers The client only has a post-mutation because you may need to do some extra work after data from the server has been loaded into the client-side database. On the server, I don’t think that there’s a similar issue — what do you want the server-side post mutation for?

mitchelkuijpers 2016-10-07T13:01:30.002012Z

For example we do a optimistic update where we delete something, we just delete it and then when the delete was successfull we want to show a extra flag

mitchelkuijpers 2016-10-07T13:01:57.002013Z

For this update we don’t need another read, that is the biggest problem

mitchelkuijpers 2016-10-07T13:02:34.002014Z

I don’t want it serverside btw

mitchelkuijpers 2016-10-07T13:02:48.002015Z

I just want a post remote mutations is done (if that makes sense)

mitchelkuijpers 2016-10-07T13:02:53.002016Z

like post-mutation for reads

2016-10-07T13:06:59.002017Z

I’m not sure I understand why knowing that the server-side mutation has completed is important. If the server-side deletion wasn’t successful and you throw an error, it will be propagated to the client. If the server-side deletion was successful, why indicate to the client that the happy path was successful? Isn’t that implied by the fact that an error wasn’t thrown?

mitchelkuijpers 2016-10-07T13:07:50.002018Z

I get your point but that does not mean our UX designer agrees 😛

2016-10-07T13:08:41.002019Z

haha fair enough, so the desire is to have an indication that the remote worked? You’d probably have to implement websockets and send some kind of message back, but you’d have to ask @mahinshaw more about that

mitchelkuijpers 2016-10-07T13:08:56.002020Z

I just want to know that the mutation http-call is doen

mitchelkuijpers 2016-10-07T13:09:00.002021Z

s/doen/done

mitchelkuijpers 2016-10-07T13:09:04.002022Z

oh this is not hipchat 😛

2016-10-07T13:09:40.002023Z

yeah all of the networking stuff is abstracted away

mitchelkuijpers 2016-10-07T13:09:44.002024Z

Let’s say you have a form on which you want to do a save and when the save is done you want to close a modal, If you want to implement this you have to have a read after

mitchelkuijpers 2016-10-07T13:10:29.002025Z

We misunderstood post-mutation to do this (because we used to have something similar in our homegrown om.next parser)

2016-10-07T13:11:53.002026Z

Right, except a follow on read in the deletion case would just remove the deleted item the client-side database

2016-10-07T13:12:11.002027Z

You wouldn’t know that the particular item that was just deleted had been deleted successfully

mitchelkuijpers 2016-10-07T13:12:32.002028Z

True

2016-10-07T13:12:58.002029Z

So either your server would have to return some piece of information that indicated which item was previously deleted, and you could compare that with some saved state of which item is currently being deleted…

mitchelkuijpers 2016-10-07T13:13:04.002030Z

Maybe we are thinking wrong… But it can be hard to convince our UX designer of this. Also we have to integrate with atlassian products which don’t do optimistic updates

mitchelkuijpers 2016-10-07T13:13:37.002031Z

So our users then start refreshing after changes to be sure that the changes are saved

2016-10-07T13:14:22.002032Z

I see

mitchelkuijpers 2016-10-07T13:15:32.002033Z

So we would like to start a progress indicator when a thing is being updated for example and then a post-remote-mutation on which we can reset that indicator

2016-10-07T13:16:26.002034Z

If we wanted to integrate that kind of functionality into untangled, I think we would have to do it in the networking layer — untangled.client.impl.network

2016-10-07T13:17:30.002035Z

In the UntangledNetwork’s send protocol method, which would have to gain access to the app state and put some marker indicating that the post returned successfully

2016-10-07T13:17:39.002036Z

not exactly sure how that would work

mitchelkuijpers 2016-10-07T13:18:19.002037Z

Me neither I am just blurting this out, I get that this does not really fit with the "untangled way"

2016-10-07T13:18:20.002040Z

also, so you know, you are free to implement your own UntangledNetwork

2016-10-07T13:19:04.002041Z

yeah it’s not the intended pattern as I understand it, but I can also understand why your UX person would want it.

2016-10-07T13:22:15.002042Z

let’s see what others think when they get a chance to browse

2016-10-07T13:22:59.002043Z

I think websockets or a custom untangled network are the best options

mitchelkuijpers 2016-10-07T13:23:39.002044Z

I don’t really get why we would need websockets for this

mitchelkuijpers 2016-10-07T13:23:53.002045Z

and http call has start -> end

2016-10-07T13:26:26.002046Z

Well I’m no expert on websockets 🙂

mitchelkuijpers 2016-10-07T13:26:44.002047Z

Me neither 🙂

2016-10-07T13:26:45.002048Z

My very cursory understanding is that with websockets the server can push data to the client

2016-10-07T13:27:13.002049Z

So if the client says “delete this thing” the server could respond with “this thing was deleted"

2016-10-07T13:27:50.002051Z

In a more declarative way, instead of just making the inference from the closed xhr

mitchelkuijpers 2016-10-07T13:29:49.002053Z

Aha that’s true, but when I send to the server (delete x) and then the xhr returns with a 200 this could mean the same. But I think you get the problem 🙂

2016-10-07T13:30:22.002054Z

yes, it is the same, AND because websockets is a separate untangled library you might have more flexibility with it than the standard networking

mitchelkuijpers 2016-10-07T13:30:39.002056Z

Ah that’s true

mitchelkuijpers 2016-10-07T13:30:49.002057Z

But then we need another load balancer 😛

mitchelkuijpers 2016-10-07T13:32:14.002058Z

But thnx we’ll see what the others have to say

tony.kay 2016-10-07T14:58:10.002059Z

@mitchelkuijpers So, if what you want to do is simulate sync processing, then there is a way to do that:

tony.kay 2016-10-07T14:58:30.002060Z

Send the mutation, and follow it with a remote read for the status that blocks

tony.kay 2016-10-07T14:59:19.002061Z

something like: (om/transact! this '[(delete/thing) (untangled/load {:query [:did-delete-finish?]})])

tony.kay 2016-10-07T14:59:29.002062Z

the load can have a post-mutation as well, of course

tony.kay 2016-10-07T14:59:49.002063Z

basically, any time you want a "return result" just follow it with a remote read

tony.kay 2016-10-07T15:00:11.002064Z

if you need to identify "which one", then send a tempid with the delete (which will get remapped in the app state and network queue)

tony.kay 2016-10-07T15:01:20.002065Z

(let [did (om/tempid)] (om/transact! this `[(delete {:id did}) (untangled/load  {:query [(:finished? {:id did})] ...})]))

tony.kay 2016-10-07T15:02:09.002067Z

process the delete in a future, and put it in a server-side tracking map with that ID

tony.kay 2016-10-07T15:02:11.002068Z

etc etc

tony.kay 2016-10-07T15:02:47.002069Z

@ethangracer Make sure you put this in the interactions stuff you're doing in dev guide ^^^ 🙂

tony.kay 2016-10-07T15:03:26.002070Z

would not hurt to have a few cookbook recipes around this kind of thing. Return values from remote mutations seems to be a hot topic, esp with ppl integrating with legacy stuff

mitchelkuijpers 2016-10-07T15:04:31.002071Z

Aha this would be nice to have in the docs

mitchelkuijpers 2016-10-07T15:05:28.002072Z

Thnx @tony.kay

2016-10-07T15:05:40.002073Z

@tony.kay not sure I fully understand. If you are deleting something that already exists, you currently have a database ID for it. what’s the tempid for?

tony.kay 2016-10-07T15:07:22.002074Z

to track the operation itself...you want to block on the thing that is doing the delete

tony.kay 2016-10-07T15:07:44.002075Z

otherwise you might get a false negative (yep, that thing is still here) if you processed the delete in the bg

tony.kay 2016-10-07T15:07:57.002076Z

then again, if you made delete itself sync on the server, then you could use the object id

tony.kay 2016-10-07T15:08:08.002077Z

so yeah, I was making that example more complicated than it needs to be

tony.kay 2016-10-07T15:08:44.002078Z

Untangled guarantees writes before reads, BTW within a single transaction...that should be documented as well

tony.kay 2016-10-07T15:09:00.002079Z

e.g. flipping the load and the delete would still work because they would be reorderd in the xaction

tony.kay 2016-10-07T15:10:59.002082Z

two separate calls to om/transact! would also follow this reordering rule, assuming you did it on the same user interaction (UI thread never released)

tony.kay 2016-10-07T15:13:13.002083Z

This could be a potential source of confusion. The reasoning is that any loads are for the client...and mutations could not possibly rely on the information they provide (since it has not arrived before the mutation is queued). Thus, processing the reads before a mutation can only ever give you out-of-date data

tony.kay 2016-10-07T15:13:28.002084Z

Of course, if you wanted out-of-date data, then you're screwed 🙂

tony.kay 2016-10-07T15:14:20.002085Z

^^^ @mahinshaw @adambros this info might also be of interest in docs you might be working on

tony.kay 2016-10-07T15:15:30.002086Z

@mitchelkuijpers would love a contribution to the cookbook if you'd care to write one about the case you asked about, but in more general-purpose terms

tony.kay 2016-10-07T15:15:51.002087Z

if you'd need help getting started on that, I'd be glad to show you around

mitchelkuijpers 2016-10-07T15:20:12.002088Z

Yeah definately

mitchelkuijpers 2016-10-07T15:20:19.002089Z

but that will be this weekend then is that okay?

tony.kay 2016-10-07T15:26:55.002090Z

any time is fine by me 🙂

tony.kay 2016-10-07T15:27:10.002091Z

if you see me online, you can ping me

mitchelkuijpers 2016-10-07T15:28:04.002092Z

Cool thnx man