Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Most ui components allow users to run custom logic on certain events. (ex. on initialize, on value change, on before save, ...)
These customizable events are available directly from the repository, as attributes.
The attributes support simple JavaScript syntax:

Sample attribute value
EventAttribute: '$ app.domain.function(eventSource);'

The attributes require the value to start with '$', denoting that the used syntax will be JavaScript. (at the moment only JavaScript is supported)

Most of the time, the events will require access to the context of the event. (the object that is triggering the event, the screen, ...)
For that we introduced the following reserved keywords:

  • self (deprecated) - the underlying dynObj of the triggering object
  • oSelf (deprecated) - the underlying controller of the triggering object
  • eventSource - the object on which the event is triggered
  • eventOrigin - the container from where the current screen was launched

Decentralized client logic:

As of SWAT 22.13.0, support for decentralized client logic has been introduced.
As seen in the example above, the functions need to be available in the global context to be able to reference them.
This means having to maintain that global context to avoid conflicts and having to reference the events by their full path.
Moreover, this also means that all the client logic is loaded in the main bundle.

With the decentralized client logic, the goal was to address all the issues mentioned above to improve performance and allow users to focus on the client logic itself and not its infrastructure.
With this approach, users are able to specify and reference custom client logic without including it in the global context and without preloading it. (it will  be lazy loaded on screen launch)

A new attribute 'EventNamespace' has been introduced for all repository objects.
When the attribute is assigned a namespace (ex. 'app.domain'), on screen launch, the corresponding file will be lazy loaded and injected into the specified namespace.
With this approach, the events will be specified exactly as above, there is no change in how the events are referenced, the main change is in how the logic is lazy loaded when required.
This means that the initial example from above remains as it is:

Simple event namespace
EventNamespace: 'app.domain'
EventAttribute: '$ app.domain.function(eventSource);'


This approach still requires users to specify the correct namespace in the events themselves.
We have simplified this with the introduction of a new reserved word 'eventNamespace', which will automatically map to the 

  • No labels