@@ -12,11 +12,13 @@ Here are valuable properties of the `State Class` listed.
1212:::
1313
1414## ` agileInstance `
15- Agile Instance to which the State belongs
15+
16+ The [ ` agileInstance ` ] ( ../agile-instance/Introduction.md ) to which the State belongs.
1617``` ts
1718MY_STATE .agileInstance (); // Returns a Agile Instance
1819```
19- Note that it is stored as a function in the State, to avoid endless deep classes.
20+ Be aware that the ` agileInstance ` property is of the type function,
21+ to avoid endless deep classes.
2022
2123
2224
@@ -29,10 +31,16 @@ Note that it is stored as a function in the State, to avoid endless deep classes
2931
3032
3133## ` key `
32- Current key/name of the State.
33- It is used to uniquely identify the State.
34- Besides getting the ` key ` , we can also assign a new ` key ` with help of this property.
35- ``` ts
34+
35+ The current ` key/name ` of the State,
36+ which is used to uniquely identify the State.
37+ ``` ts {2}
38+ const MY_STATE = App .createState (123 , {key: ' jeffKey' });
39+ MY_STATE .key ; // Returns 'jeffKey'
40+ ```
41+ Besides, accessing the ` key ` ,
42+ we can also assign a new ` key ` through this property to the State.
43+ ``` ts {1}
3644MY_STATE .key = " myCoolState" ;
3745MY_STATE .key ; // Returns 'myCoolState'
3846```
@@ -48,13 +56,14 @@ MY_STATE.key; // Returns 'myCoolState'
4856
4957
5058## ` valueType `
51- Current type of the value.
59+
60+ Represents the current ` type ` of the State value.
5261``` ts {2}
5362MY_STATE .type (String );
5463MY_STATE .valueType ; // Returns 'string'
5564```
56- This property is only useful if you are using Javascript,
57- because for Typescript there are better solutions, like generic types.
65+ This property is thought to help Javascript users to get a basic type safety.
66+ In Typescript, we recommend using generic types to reach such goal .
5867``` ts
5968App .createState <string >(" see generic types are sick" );
6069```
@@ -70,7 +79,8 @@ App.createState<string>("see generic types are sick");
7079
7180
7281## ` isSet `
73- If the current State Value differ from the initial State Value.
82+
83+ Is ` ture ` , if the current State value differs from the initial State value.
7484``` ts {2,4}
7585const MY_STATE = App .createState (" jeff" );
7686MY_STATE .isSet ; // Returns false
@@ -89,18 +99,22 @@ MY_STATE.isSet; // Returns true
8999
90100
91101## ` isPlaceholder `
92- If the State is a placeholder.
102+
103+ Determines if the State is a ` placeholder ` .
93104``` ts
94105MY_STATE .isPlaceholder ; // Returns 'false'
95106```
96- For instance, it might be a placeholder if it hasn't been instantiated yet, but AgileTs needs to hold a reference to it.
97- This is the case if we bind a maybe not existing Group with the ` getGroupWithReference ` function to a Component.
98- Then AgileTs creates a placeholder Group for us, to ensure that the Component rerender whenever
99- the real Group got created.
107+ States are, for example, ` placeholder ` when AgileTs needs to hold a reference to them,
108+ although they aren't instantiated yet.
109+ This might be the case by using ` getGroupWithReference() ` ,
110+ which returns a ` placeholder ` Group (extension of State), if the Group doesn't exist,
111+ to hold a reference to it.
100112``` ts
101113const myGroup = useAgile (MY_COLLECTION .getGroupWithReference (" group1" )); // Causes rerender if Group got created
102114const myGroup2 = useAgile (MY_COLLECTION .getGroup (" group2" )); // Doesn't Causes rerender if Group got created
103115```
116+ This reference is essential to rerender the Component,
117+ whenever the Group got instantiated.
104118
105119
106120
@@ -113,7 +127,9 @@ const myGroup2 = useAgile(MY_COLLECTION.getGroup("group2")); // Doesn't Causes r
113127
114128
115129## ` initialStateValue `
116- The first Value which got firstly assigned to the State.
130+
131+ The initial ` value ` of the State,
132+ so the ` value ` that got firstly assigned to it.
117133``` ts {4}
118134const MY_STATE = App .createState (" jeff" );
119135MY_STATE .set (" frank" );
@@ -132,11 +148,17 @@ MY_STATE.initialStateValue; // Returns 'jeff'
132148
133149
134150## ` value `
135- The current Value of the State.
136- Besides getting the ` value ` , we can also assign a new ` value ` with help of this property.
137- ``` ts
138- MY_STATE .value = " myCoolValue" ;
139- MY_STATE .value ; // Returns 'myCoolValue'
151+
152+ The current ` value ` of the State.
153+ ``` ts {2}
154+ const MY_STATE = App .createState (123 );
155+ MY_STATE .key ; // Returns '123'
156+ ```
157+ Besides, accessing the ` value ` ,
158+ we can also assign a new ` value ` through this property to the State.
159+ ``` ts {1}
160+ MY_STATE .value = 9999 ;
161+ MY_STATE .value ; // Returns '9999'
140162```
141163
142164
@@ -150,7 +172,8 @@ MY_STATE.value; // Returns 'myCoolValue'
150172
151173
152174## ` previousStateValue `
153- The State Value, which has been assigned to the State, before the current active Value.
175+
176+ The State ` value ` that got assigned previously.
154177``` ts
155178const MY_STATE = App .createState (" hello" );
156179MY_STATE .set (" bye" );
@@ -168,18 +191,21 @@ MY_STATE.previousState; // Returns 'hello'
168191
169192
170193## ` nextStateValue `
171- The State Value, which will be assigned to the State as next.
172- Often this is the current Value, because AgileTs is pretty fast in assigning new Values 🚀.
194+
195+ The State ` value ` that will be assigned next to the State as current ` value ` .
196+ Often it is the current ` value ` , because AgileTs assigns new ` values ` pretty fast 🚀.
173197``` ts {2}
174198MY_STATE .set (1 );
175199MY_STATE .nextStateValue ; // Returns '1'
200+ MY_STATE .value ; // Returns '1'
176201```
177- The ` nextStateValue ` will be used as next value, if we ingest the State without any specific new value into the runtime.
202+ The ` nextStateValue ` will be used as the next ` value ` ,
203+ if the State got ingested into the ` runtime ` without any specific new ` value ` .
178204``` ts {2}
179- const MY_ARRAY = App .State ([ 1 , 2 , 3 ] );
180- MY_ARRAY . nextState . push ( 4 ) ;
181- MY_ARRAY .ingest ();
182- MY_STATE .value ; // Returns '[1, 2, 3, 4] '
205+ const MY_STATE = App .State (' hans ' );
206+ MY_STATE . nextStateValue = ' jeff ' ;
207+ MY_STATE .ingest ();
208+ MY_STATE .value ; // Returns 'jeff '
183209```
184210
185211
@@ -193,9 +219,10 @@ MY_STATE.value; // Returns '[1, 2, 3, 4]'
193219
194220
195221## ` isPersisted `
196- If the State Value got successfully persisted into an external Storage like the [ Local Storage] ( https://developer.mozilla.org/de/docs/Web/API/Window/localStorage ) .
222+
223+ If the State ` value ` is stored into an external Storage like the [ Local Storage] ( https://developer.mozilla.org/de/docs/Web/API/Window/localStorage ) .
197224``` ts {1,3}
198225MY_STATE .isPersisted ; // Returns 'false'
199226MY_STATE .persist ();
200- MY_STATE .isPersisted ; // Returns 'true'
227+ MY_STATE .isPersisted ; // Returns 'true' if the persist was successful
201228```
0 commit comments