Aller au contenu principal

Class: LunaticVariablesStore

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

Constructors

Constructor

new LunaticVariablesStore(): LunaticVariablesStore

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

Returns

LunaticVariablesStore

Properties

PropertyModifierTypeDefault valueDefined in
autoCommitpublicbooleanfalsesrc/use-lunatic/commons/variables/lunatic-variables-store.ts:66
updatedAtpublicTimekeyundefinedsrc/use-lunatic/commons/variables/lunatic-variables-store.ts:67

Accessors

interpretCount

Get Signature

get interpretCount(): number

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

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

Commit all changes in the queue

Returns

void


debug()

debug(): void

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

Returns

void


enqueueSet()

enqueueSet(name, value, args): void

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

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

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

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

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

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

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

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


makeFromObject()

static makeFromObject(values): LunaticVariablesStore

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

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

Parameters

ParameterType
valuesRecord<string, unknown>

Returns

LunaticVariablesStore


makeFromSource()

static makeFromSource(source, data, changeHandler?, disableCleaning?, autoCommit?): LunaticVariablesStore

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

Parameters

ParameterType
sourceLunaticSource
dataPartial
changeHandler?RefObject<undefined | (event) => void>
disableCleaning?boolean
autoCommit?boolean

Returns

LunaticVariablesStore