What is difference between synchronous client action and asynchronous client action?
Question

Take into account that calling synchronous client actions in JavaScript must be coded differently than calling asynchronous client actions:

  • When calling synchronous client actions the return value is a simple JavaScript object containing the output parameters.

  • When calling asynchronous client actions a promise is returned, i.e. the returned values will not be available immediately after returning to the caller context. If you don't take this into account in your JavaScript code, the subsequent logic may be operating on invalid data.



I was reading the documentation and I see synchronous client action and asynchronous client action.

Hi Ramakrushnarao, 

In general, synchronous actions are blocking; this means that only one operation can happen at a time, A must finish before B starts. On the other hand, asynchronous actions are non-blocking; that is, if A is defined to be asynchronous, B can begin before the execution of A ends. The full explanation is more complex, but in general it should give you an idea of a couple of scenarios where it can be beneficial to run subsequent actions/lines of code without having to wait for the previous one to finish completely.

In the context of a Client Action, you can use asynchronous operations when you want to do an operation that is somewhat time-consuming (e.g. fetching a resource, performing a Server Action) without blocking your main thread. This is because all Client-facing logic in OutSystems reactive applications is implemented using JavaScript, and javaScript is single-threaded. Reading some common documentation about asynchronous JavaScript (such as this article) should help you gain a broader understanding of asynchronous operations, their benefits and common use cases/patterns.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.