Corredor Client
Corredor client is mainly responsible for:
-
Script registration on the event bus,
-
registering available UI hooks,
-
script execution; either locally or on the server.
Event bus
Any executable automation script is registered on the event bus. Whenever any part of the system might require a script execution, it dispatches an event on the event bus and any registered script that conforms to the requirements is executed on the Corredor server.
The event bus concept follows the same pattern as the Corteza server does. |
- Fetch available script bundle from the Corteza server
-
This provides available client-script automation scripts defined for the given application. This allows us to register available client-scripts.
- Fetch available scripts from the Corteza server
-
This provides a full automation script list, including invalid scripts (those that didn’t compile successfully) — these are excluded. This allows us to register explicit server-scripts.
- Prepare a lightweight script representation
-
Define a lightweight
Handler
object for easier execution determination and script identification. Execution is performed by the handler function that allows a bit more flexibility on how to handle each script type. - Register the script on the event bus
-
Register the above simplified automation script on the event buss.
Now when it comes to script execution, this is invoked by dispatching an event on the event bus. To outline the flow:
- Dispatch the event on the event bus
-
An event is an object that allows the event bus to determine what automation scripts should be executed and their execution context/arguments.
- Execute the scripts
-
Iterate and execute any automation script that conforms to the dispatched event. This can be done either synchronously or asynchronously.
A big difference between server-side and client-side execution is that client-side arguments are provided as references and not as copied objects. Any change done to the original object is reflected to the original object. |
UI hooks
A UI hook defines a component that represents an explicit automation script — either a client-script or a server-script. UI hooks mainly define the component properties — what element to render, styling, what script should be executed, additional context, …
It is up to the web-app to render these components and dispatch events on the event bus when needed.
Script execution
Corredor client is able to interact with some UI elements such as |
- Explicit
-
Explicit scripts are invoked by the user by explicitly invoking the above mentioned UI hooks. The web-app creates an event and dispatches it on the event bus. The handler function requests the script’s execution on the Corteza server.
An event caused by an explicit script will provide the script name that should be executed. Implicit events do not. |
- Implicit
-
These are triggered as a side-effect of another operation, such as form submission, view render, validation error, … Each part of the system that performs some operation that may invoke script execution generates an event and dispatches it on the event bus.