OpenWGA 7.9 - OpenWGA Concepts and Features
Design and development » TMLScript » TMLScript ObjectsTMLScript globals
Instead of instanciating a TMLScript object each time you need it you can define the script module as "global".
A global TMLScript module is registered by calling
WGA.app().managedGlobal(<global-name>, <tmlscript-module-design-locator>)
This is typically done in a connect script of an app.
Sample:
WGA.app().managedGlobal("Products", $.Products)
You can access this "global" in any TML or TMLScript inside the design of your app (but not outside) through the global name you registered it:
Products.someMethod()
The TMLScript object itself is instanciated by the OpenWGA runtime. By default the object will be instanciated the moment it is used the first time (and it will not be instanciated if never used) and stays in memory until the app is disconnected. You can however tell OpenWGA to instanciate a new object on each HTTP request or for each HTTP session by specifying an optional "scope" parameter when registering:
WGA.app().managedGlobal(<global-name>, <tmlscript-module-design-locator>, {
scope: <scope>
})
Available Scopes are
- WGA.Scopes.APP (the default)
- WGA.Scopes.CALL (new object for each HTTP request)
- WGA.Scopes.SESSION (new object for each HTTP session)
- WGA.Scopes.TMLPAGE (new object for each Websocket connection)
- WGA.Scopes.FORM (new object for each TMLForm)