API: globals
Source:
core/globals.ts
API Globals
- Provides a static interface for accessing and manipulating global application variables, typically backed by a central configuration or registry.
Usage
import { globals } from "sdk/core";
import { response } from "sdk/http";
globals.set("attr1", "value1");
let attr = globals.get("attr1");
response.println("[Attribute]: " + attr);
response.flush();
response.close();Classes
Globals
Interface representing a map of global variable names to their string values.
Methods
get
get (name:string):string|undefinedRetrieves the value of the global variable with the specified name.
@param name The name of the global variable.
@returns The variable's value as a string, orundefinedif the variable is not set or its value is null.
set
set (name:string, value:string):voidSets the value of a global variable.
If the variable already exists, its value is overwritten.
@param name The name of the global variable.
@param value The value to set (must be a string).
list
list ():GlobalsValuesRetrieves a map of all global variables currently defined in the application.
@returns A {@link GlobalsValues} object containing all global variables as key-value pairs.