Aller au contenu principal

Class: LunaticVariablesStore

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:76

Constructors​

Constructor​

new LunaticVariablesStore(): LunaticVariablesStore

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:87

Returns​

LunaticVariablesStore

Properties​

PropertyModifierTypeDefault valueDefined in
autoCommitpublicbooleanfalsesrc/use-lunatic/commons/variables/lunatic-variables-store.ts:84
updatedAtpublicTimekeyundefinedsrc/use-lunatic/commons/variables/lunatic-variables-store.ts:85

Accessors​

interpretCount​

Get Signature​

get interpretCount(): number

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:380

Retrieve the number of interpret() run (used in testing only).

Returns​

number

Methods​

commit()​

commit(): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:229

Commit all changes in the queue

Returns​

void


debug()​

debug(): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:385

Returns​

void


enqueueSet()​

enqueueSet(name, value, args?, forcedChangedKey?): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:190

Transactional setter that will change data only when commit() is called

Parameters​

ParameterType
namestring
valueunknown
argsPick<EventArgs["change"], "iteration" | "cause">
forcedChangedKey?string

Returns​

void


get()​

get<T>(name, iteration?): T | null

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:180

Retrieve variable value

Type Parameters​

Type Parameter
T

Parameters​

ParameterType
namestring
iteration?IterationLevel

Returns​

T | null


off()​

off<T>(eventName, cb): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:372

Detach a listener

Type Parameters​

Type Parameter
T extends "change"

Parameters​

ParameterType
eventNameT
cb(e) => void

Returns​

void


on()​

on<T>(eventName, cb): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:362

Bind event listeners

Type Parameters​

Type Parameter
T extends "change"

Parameters​

ParameterType
eventNameT
cb(e) => void

Returns​

void


run()​

run(expression, args?): unknown

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:350

Run a VTL expression

Parameters​

ParameterType
expressionstring
args{ deps?: string[]; iteration?: IterationLevel; }
args.deps?string[]
args.iteration?IterationLevel

Returns​

unknown


set()​

set(name, value, args?): LunaticVariable

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:245

Set variable value

Parameters​

ParameterType
namestring
valueunknown
argsPick<EventArgs["change"], "iteration" | "cause" | "ignoreIterationOnScalar">

Returns​

LunaticVariable


setCalculated()​

setCalculated(name, expression, __namedParameters?): LunaticVariable

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:282

Register calculated variable

Parameters​

ParameterType
namestring
expressionstring
__namedParameters{ dependencies?: string[]; dimension?: number; iterationDepth?: number; shapeFrom?: string | string[]; }
__namedParameters.dependencies?string[]
__namedParameters.dimension?number
__namedParameters.iterationDepth?number
__namedParameters.shapeFrom?string | string[]

Returns​

LunaticVariable


setGlobal()​

setGlobal(name, __namedParameters): LunaticVariable

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:318

Register global variable

Parameters​

ParameterType
namestring
__namedParameters{ dependencies?: string[]; globalDependencies?: Map<unknown, string>; shapeFrom?: string | string[]; }
__namedParameters.dependencies?string[]
__namedParameters.globalDependencies?Map<unknown, string>
__namedParameters.shapeFrom?string | string[]

Returns​

LunaticVariable


unqueueSet()​

unqueueSet(name, args?): void

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:214

Parameters​

ParameterType
namestring
argsPick<EventArgs["change"], "iteration" | "cause">

Returns​

void


makeFromObject()​

static makeFromObject(values?): LunaticVariablesStore

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:169

Create a new store from an object (useful for testing)

Parameters​

ParameterType
valuesRecord<string, unknown>

Returns​

LunaticVariablesStore


makeFromSource()​

static makeFromSource(source, data, options?): LunaticVariablesStore

Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:91

Parameters​

ParameterType
sourceLunaticSource
dataLunaticData
options{ autoCommit?: boolean; changeHandler?: RefObject<((event) => void) | undefined>; disableCleaning?: boolean; }
options.autoCommit?boolean
options.changeHandler?RefObject<((event) => void) | undefined>
options.disableCleaning?boolean

Returns​

LunaticVariablesStore