@@ -140,7 +140,14 @@ export interface StateMethods<S> {
140140 * ```
141141 */
142142 readonly value : S ;
143+ /**
144+ * True if state value is not yet available (eg. equal to a promise)
145+ */
143146 readonly promised : boolean ;
147+ /**
148+ * If a state was set to a promise and the promise was rejected,
149+ * this property will return the error captured from the promise rejection
150+ */
144151 readonly error : StateErrorAtRoot | undefined ;
145152 /**
146153 * Unwraps and returns the underlying state value referred by
@@ -176,24 +183,26 @@ export interface StateMethods<S> {
176183 * value with the argument converted to string and sets the result to the state.
177184 */
178185 merge ( newValue : SetPartialStateAction < S > ) : void ;
179- nested < K extends keyof S > ( key : K ) : State < S [ K ] > ;
180186 /**
181- * Maps this state to the result via the provided action .
182- *
183- * @param action mapper function
187+ * Returns nested state by key .
188+ * `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`,
189+ * but also works for properties, which names collide with names of state methods.
184190 *
185- * @param onPromised this will be invoked instead of the action function,
186- * if a state value is unresolved promise.
187- * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
191+ * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)
188192 *
189- * @param onError this will be invoked instead of the action function,
190- * if a state value is a promise resolved to an error.
191- * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
193+ * @param key child property name or index
194+ */
195+ nested < K extends keyof S > ( key : K ) : State < S [ K ] > ;
196+ /**
197+ * Runs the provided action callback with optimised re-rendering.
198+ * Updating state within a batch action does not trigger immediate rerendering.
199+ * Instead, all required rerendering is done once the batch is finished.
192200 *
193- * @param context if specified, the callbacks will be invoked in a batch.
194- * Updating state within a batch does not trigger immediate rerendering.
195- * Instead, all required rerendering is done once once the batch is finished.
196201 * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates
202+ *
203+ * @param action callback function to execute in a batch
204+ *
205+ * @param context custom user's value, which is passed to plugins
197206 */
198207 batch < R , C > ( action : ( s : State < S > ) => R , context ?: Exclude < C , Function > ) : R ;
199208 /**
0 commit comments