clearVar
Resets an App Var to the initial value you set when you declared it in LucyStudio.
Parameters
appVarName(string): a variable name predefined in the LucyStudio app settings
Returns
None (void)
Description
$app.clearVar does not reset the given App Var to null — it restores the default (initial) value you set when you declared the variable in the LucyStudio designer. Internally it calls LucyVarMngr.clearVarValue(appVarMap, appVarName).
The variable is app-wide, so calling clearVar in one Form means every other Form reads the reset value too.
⚠️ After
clearVar, the value is the default defined in LucyStudio, notnull. Check the actual value withgetVarafter resetting.
$app vs $form vs $page comparison
| Item | $app.clearVar | $form.clearVar |
|---|---|---|
| Scope | Shared across the app | Current Form instance |
| Reset target | Default declared in the LucyStudio app | Default declared in the LucyStudio form |
| Lifecycle | Kept while the app runs | Destroyed when the Form closes |
| Effect on other Forms | ✅ Applies to every Form | ❌ Only that Form |
Example
// Restore an App Var to the initial value declared in LucyStudio
$app.clearVar("loginUserId");
var restored = $app.getVar("loginUserId");
$log.i("초기화 후 userId:", restored); // Prints the default declared in LucyStudio
// Reset several App Vars on logout
$app.clearVar("loginUserId");
$app.clearVar("theme");
$app.clearVar("cartItems");
Related
$app.setVar(appVarName, data)— set an App Var$app.getVar(appVarName)— read an App Var$form.clearVar(localVarName)— reset a Form-level variable (valid only in that Form)