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
| Property | Modifier | Type | Default value | Defined in |
|---|---|---|---|---|
autoCommit | public | boolean | false | src/use-lunatic/commons/variables/lunatic-variables-store.ts:66 |
updatedAt | public | Timekey | undefined | src/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
| 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:146
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:285
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:275
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:263
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:190
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:227
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
makeFromObject()
staticmakeFromObject(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
| Parameter | Type |
|---|---|
values | Record<string, unknown> |
Returns
LunaticVariablesStore
makeFromSource()
staticmakeFromSource(source,data,changeHandler?,disableCleaning?,autoCommit?):LunaticVariablesStore
Defined in: src/use-lunatic/commons/variables/lunatic-variables-store.ts:73
Parameters
| Parameter | Type |
|---|---|
source | LunaticSource |
data | Partial |
changeHandler? | RefObject<undefined | (event) => void> |
disableCleaning? | boolean |
autoCommit? | boolean |
Returns
LunaticVariablesStore