Aller au contenu principal

Class: LunaticVariablesStore

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

Constructors

Constructor

new LunaticVariablesStore(): LunaticVariablesStore

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

Returns

LunaticVariablesStore

Properties

PropertyModifierTypeDefault valueDefined in
autoCommitpublicbooleanfalsesrc/use-lunatic/commons/variables/lunatic-variables-store.ts:73
updatedAtpublicTimekeyundefinedsrc/use-lunatic/commons/variables/lunatic-variables-store.ts:74

Accessors

interpretCount

Get Signature

get interpretCount(): number

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

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:201

Commit all changes in the queue

Returns

void


debug()

debug(): void

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

Returns

void


enqueueSet()

enqueueSet(name, value, args): void

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

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

Parameters

ParameterType
namestring
valueunknown
argsPick<{[extra: string]: unknown; cause?: "cleaning" | "resizing"; ignoreIterationOnScalar?: boolean; iteration?: IterationLevel; name: string; value: unknown; }, "iteration" | "cause">

Returns

void


get()

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

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

Retrieve variable value

Type Parameters

Type Parameter
T

Parameters

ParameterType
namestring
iteration?IterationLevel

Returns

null | T


off()

off<T>(eventName, cb): void

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

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:330

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:318

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:213

Set variable value

Parameters

ParameterType
namestring
valueunknown
argsPick<{[extra: string]: unknown; cause?: "cleaning" | "resizing"; ignoreIterationOnScalar?: boolean; iteration?: IterationLevel; name: string; value: unknown; }, "iteration" | "cause" | "ignoreIterationOnScalar">

Returns

LunaticVariable


setCalculated()

setCalculated(name, expression, __namedParameters): LunaticVariable

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

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:286

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


makeFromObject()

static makeFromObject(values): LunaticVariablesStore

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

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:80

Parameters

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

Returns

LunaticVariablesStore