Different API

Started by Carlo Didier, August 20, 2018, 02:51:05 PM

Previous topic - Next topic

Carlo Didier

I know this has practically no chance to be realized, but if nobody asks ...

As I am constantly struggling with the asynchronicity in the IMWS interface in iMatch scripts (there are extremely huge disadvantages and unnecessary complications for all my scripts and absolutely no advantages whatsoever), my thought was this:
As IMWS is just a web front-end and the internal workings behind it are definitely synchronous, woudn't it be possible to access those internal synchronous functions directly?

So we would have the choice of using the asynchronous IMWS functions where appropriate and the direct functions where those are better suited to the task.

Mario

#1
All web services are asynchronous by nature. That is one of the ley aspects of all web technologies.
There is no way to make a browser stop dead when it makes an AJAX request (web service call) and to wait until the request is finished.

If you cannot handle promises and asynchronous processing in your app, use async / await to make your code behave synchronous or to make program flow easier.
This is rarely needed but can be helpful. I use that, for example, in the App Translator and the Attribute Importer apps.

Use your favorite search engine to find one of the many tutorials on async / await. Search for JavaScript async await


-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

Quote from: Mario on August 20, 2018, 03:12:33 PM
All web services are asynchronous by nature. That is one of the ley aspects of all web technologies.
There is no way to make a browser stop dead when it makes an AJAX request (web service call) and to wait until the request is finished.
I know.

Quote from: Mario on August 20, 2018, 03:12:33 PM
If you cannot handle promises and asynchronous processing in your app, use async / await to make your code behave synchronous or to make program flow easier.
This is rarely needed but can be helpful. I use that, for example, in the App Translator and the Attribute Importer apps.

Use your favorite search engine to find one of the many tutorials on async / await. Search for JavaScript async await
I had read about that but couldn't get it to work. But if you use it in the above scripts, I'll have a look at them. Maybe I'll get it working for me too when I see a real world example.

Thanks!

Mario

#3
QuoteI know.

You usually don't want your browser to block and become unresponsive while it's pulling or pushing data. That is a BIG no-no in all things web.

All in IMWS has been written to support doing things in parallel and work on arrays and lists of stuff.


I think he explains async/await it quite well:

https://hackernoon.com/6-reasons-why-javascripts-async-await-blows-promises-away-tutorial-c7ec10518dd9?gi=82834172e856
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

Carlo Didier

I know that article (it speaks right from my heart).

Could it be that the await option didn't work in prior versions of iMatch 2017/2018?
As I understand, it is a recent addition to Node 8.

Mario

This has nothing to do with IMWS, it's a browser thing.

Chromium (that's the browser engine used by IMatch) supports async/await since version 55 (around 2016, when I recall correctly)
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook