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
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
autoCommit | public | boolean | false | src/use-lunatic/commons/variables/lunatic-variables-store.ts:73 |
updatedAt | public | Timekey | undefined | src/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
| Parameter | Type |
|---|---|
name | string |
value | unknown |
args | Pick<{[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
| Parameter | Type |
|---|---|
name | string |
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
| Parameter | Type |
|---|---|
eventName | T |
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
| Parameter | Type |
|---|---|
eventName | T |
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
| Parameter | Type |
|---|---|
expression | string |
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
| Parameter | Type |
|---|---|
name | string |
value | unknown |
args | Pick<{[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
| Parameter | Type |
|---|---|
name | string |
expression | string |
__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
| Parameter | Type |
|---|---|
name | string |
__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()
staticmakeFromObject(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
| Parameter | Type |
|---|---|
values | Record<string, unknown> |
Returns
LunaticVariablesStore
makeFromSource()
staticmakeFromSource(source,data,options):LunaticVariablesStore
Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:80
Parameters
| Parameter | Type |
|---|---|
source | LunaticSource |
data | Partial |
options | { autoCommit?: boolean; changeHandler?: RefObject<undefined | (event) => void>; disableCleaning?: boolean; } |
options.autoCommit? | boolean |
options.changeHandler? | RefObject<undefined | (event) => void> |
options.disableCleaning? | boolean |
Returns
LunaticVariablesStore