om

Please ask the channel first, not @dnolen directly!
andreasklein 2018-07-11T09:02:15.000240Z

How can I wait for a remote mutation to finish in om-next and then trigger some action?

2018-07-11T09:28:39.000285Z

You can trigger re-reads on the remote that return new data, and act based on that data.

2018-07-11T09:29:35.000024Z

If you want it to be asynchronous, you probably have to implement some kind of polling system.

andreasklein 2018-07-11T09:33:42.000274Z

@danielstockton Thank you. Could you please elaborate a bit more on this concerning a more concrete example: I have a backend function which creates a pdf and would like to redirect to that pdf after it has been created. I try to use a remote mutation ’some-key/create-pdf but don’t see how to hook in after this mutation has finished.

2018-07-11T09:41:14.000289Z

It depends whether that pdf is generated in a background job or not. Something like

`[(some-key/create-pdf) :pdf-url]
could work, if you can afford to wait for the pdf to generate before returning the response.

2018-07-11T09:42:33.000085Z

Otherwise, you could return a job-id instead of pdf-url and poll for when it's ready.

2018-07-11T09:43:37.000019Z

(by default, the backend parser is serial and executes each mutation or read in order)

2018-07-11T09:44:07.000146Z

There are ways to implement async parsers, but that's another topic

andreasklein 2018-07-11T09:45:10.000378Z

In this case :pdf-url is read before the transaction (some-key/create-pdf) is finished?

2018-07-11T09:45:57.000148Z

No, in the default case, it will be run after (some-key/create-pdf) is finished.

2018-07-11T09:46:31.000168Z

(someone please correct me if i'm horribly wrong)

andreasklein 2018-07-11T09:46:45.000372Z

Hmm. That is sadly not the behaviour I see in my code

2018-07-11T09:47:06.000131Z

Perhaps it depends on the implementation of create-pdf

andreasklein 2018-07-11T09:47:39.000007Z

I created a remote mutation that waits for 2 seconds and then finishes. In the meanwhile the :pdf-url key is read on the client

2018-07-11T09:48:20.000095Z

Whether the :pdf-url key is read on the client depends on the client side parser

2018-07-11T09:48:26.000344Z

You should also make sure that key triggers a remote read

2018-07-11T09:48:51.000309Z

Do you receive the :pdf-url read in the remote query and return :pdf-url in the remote response?

andreasklein 2018-07-11T09:50:26.000188Z

My client side read does currently not trigger a remote read

andreasklein 2018-07-11T09:50:29.000011Z

I will try that

andreasklein 2018-07-11T09:52:59.000266Z

Aha!

andreasklein 2018-07-11T09:53:13.000345Z

Now the key is read after the first transaction finishes.

🤘 1