Constructor.
Manager instance which is used for two things:
Note that this instance only keeps a weak reference to manager which can become invalid if manager gets freed by the garbage collector (see isValid).
CTRL code of the scripts that will be returned by getScript.
Optional
name: stringOptional name for the script that will be shown in error messages.
Optional
callback: WinccoaCtrlCallbackIf given, this function can be called from the CTRL script
by using the CTRL function callbackToJavaScript()
. See
WinccoaCtrlCallback for details and examples.
import {
WinccoaCtrlScriptCache,
WinccoaCtrlType,
WinccoaManager,
} from 'winccoa-manager';
const winccoa = new WinccoaManager();
async function scriptCacheTest() {
// store the script in a cache for repeated use
const cache = new WinccoaCtrlScriptCache(
winccoa,
`double simpleArgs(int x, double y, string s)
{
return (x * y) + s.length();
}`,
'simple args cache example'
);
for (let i = 1; i <= 20; i++) {
const result = (await cache
.getScript()
.start(
'simpleArgs',
[i, 34.56, 'some text'],
[WinccoaCtrlType.int, WinccoaCtrlType.double, WinccoaCtrlType.string],
)) as number;
console.log(result);
}
}
void scriptCacheTest();
Readonly
ctrlCTRL code of the scripts that will be returned by getScript.
Optional
Readonly
nameOptional name for the script that will be shown in error messages.
Returns an instance of WinccoaCtrlScript initialized with ctrlCode for manager's current user.
Cached (possibly newly created) instance of a WinccoaCtrlScript.
Helper class for caching multiple instances of a CTRL script (initialized for different users if necessary). This helps improving performance when the same CTRL script is called multiple times by the same or different users.