Skip to main content

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, not null. Check the actual value with getVar after resetting.

$app vs $form vs $page comparison

Item$app.clearVar$form.clearVar
ScopeShared across the appCurrent Form instance
Reset targetDefault declared in the LucyStudio appDefault declared in the LucyStudio form
LifecycleKept while the app runsDestroyed 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");
  • $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)