@@ -36,15 +36,21 @@ export declare type SetInitialStateAction<S> = S | Promise<S> | (() => S | Promi
3636/**
3737 * Special symbol which is used as a property to switch
3838 * between [StateMethods](#interfacesstatemethodsmd) and the corresponding [State](#state).
39+ *
40+ * [Learn more...](https://hookstate.js.org/docs/nested-state)
3941 */
4042export declare const self : unique symbol ;
4143/**
4244 * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function.
45+ *
46+ * [Learn more...](https://hookstate.js.org/docs/asynchronous-state#executing-an-action-when-state-is-loaded)
4347 */
4448export declare const postpone : unique symbol ;
4549/**
4650 * Special symbol which might be used to delete properties
4751 * from an object calling [StateMethods.set](#set) or [StateMethods.merge](#merge).
52+ *
53+ * [Learn more...](https://hookstate.js.org/docs/nested-state#deleting-existing-element)
4854 */
4955export declare const none : any ;
5056/**
@@ -64,6 +70,8 @@ export declare type InferredStateOrnullType<S> = S extends undefined ? undefined
6470 * An instance to manipulate the state in more controlled way.
6571 *
6672 * @typeparam S Type of a value of a state
73+ *
74+ * [Learn more...](https://hookstate.js.org/docs/writing-plugin)
6775 */
6876export interface PluginStateControl < S > {
6977 /**
@@ -186,13 +194,16 @@ export interface StateMethods<S> {
186194 *
187195 * @param onPromised this will be invoked instead of the action function,
188196 * if a state value is unresolved promise.
197+ * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
189198 *
190199 * @param onError this will be invoked instead of the action function,
191200 * if a state value is a promise resolved to an error.
201+ * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
192202 *
193203 * @param context if specified, the callbacks will be invoked in a batch.
194204 * Updating state within a batch does not trigger immediate rerendering.
195205 * Instead, all required rerendering is done once once the batch is finished.
206+ * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates
196207 */
197208 map < R , RL , RE , C > ( action : ( s : State < S > ) => R , onPromised : ( s : State < S > ) => RL , onError : ( e : StateErrorAtRoot , s : State < S > ) => RE , context ?: Exclude < C , Function > ) : R | RL | RE ;
198209 /**
@@ -202,10 +213,12 @@ export interface StateMethods<S> {
202213 *
203214 * @param onPromised this will be invoked instead of the action function,
204215 * if a state value is unresolved promise.
216+ * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
205217 *
206218 * @param context if specified, the callbacks will be invoked in a batch.
207219 * Updating state within a batch does not trigger immediate rerendering.
208220 * Instead, all required rerendering is done once once the batch is finished.
221+ * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates
209222 */
210223 map < R , RL , C > ( action : ( s : State < S > ) => R , onPromised : ( s : State < S > ) => RL , context ?: Exclude < C , Function > ) : R | RL ;
211224 /**
@@ -216,6 +229,7 @@ export interface StateMethods<S> {
216229 * @param context if specified, the callbacks will be invoked in a batch.
217230 * Updating state within a batch does not trigger immediate rerendering.
218231 * Instead, all required rerendering is done once once the batch is finished.
232+ * [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates
219233 */
220234 map < R , C > ( action : ( s : State < S > ) => R , context ?: Exclude < C , Function > ) : R ;
221235 /**
@@ -225,16 +239,21 @@ export interface StateMethods<S> {
225239 * The second element with be either undefined or a value of an error,
226240 * which the resolved promise rejected. The third element will be
227241 * either undefined or a value of a state, if promise is resolved.
242+ * [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state)
228243 */
229244 map ( ) : [ boolean , StateErrorAtRoot | undefined , S | undefined ] ;
230245 /**
231246 * If state value is null or undefined, returns state value.
232247 * Otherwise, it returns this state instance but
233248 * with null and undefined removed from the type parameter.
249+ *
250+ * [Learn more...](https://hookstate.js.org/docs/nullable-state)
234251 */
235252 ornull : InferredStateOrnullType < S > ;
236253 /**
237254 * Adds plugin to the state.
255+ *
256+ * [Learn more...](https://hookstate.js.org/docs/extensions-overview)
238257 */
239258 attach ( plugin : ( ) => Plugin ) : State < S > ;
240259 /**
@@ -243,6 +262,8 @@ export interface StateMethods<S> {
243262 * If a plugin has not been attached to a state,
244263 * it returns an Error as the first element.
245264 * A plugin may trhow an error to indicate that plugin has not been attached.
265+ *
266+ * [Learn more...](https://hookstate.js.org/docs/writing-plugin)
246267 */
247268 attach ( pluginId : symbol ) : [ PluginCallbacks | Error , PluginStateControl < S > ] ;
248269}
@@ -284,6 +305,10 @@ export interface StateMixinDestroy {
284305 * Type of a result of [createState](#createstate) and [useState](#usestate) functions
285306 *
286307 * @typeparam S Type of a value of a state
308+ *
309+ * [Learn more about global states...](https://hookstate.js.org/docs/global-state)
310+ * [Learn more about local states...](https://hookstate.js.org/docs/local-state)
311+ * [Learn more about nested states...](https://hookstate.js.org/docs/nested-state)
287312 */
288313export declare type State < S > = StateMixin < S > & ( S extends ReadonlyArray < ( infer U ) > ? ReadonlyArray < State < U > > : S extends ( true | false ) ? Omit < StateMethods < boolean > , keyof StateMixin < S > > : S extends ( undefined | null | number | boolean | string | bigint ) ? Omit < StateMethods < S > , keyof StateMixin < S > > : S extends object ? {
289314 readonly [ K in keyof Required < S > ] : State < S [ K ] > ;
@@ -350,6 +375,8 @@ export interface PluginCallbacksOnBatchArgument {
350375/**
351376 * For plugin developers only.
352377 * Set of callbacks, a plugin may subscribe to.
378+ *
379+ * [Learn more...](https://hookstate.js.org/docs/writing-plugin)
353380 */
354381export interface PluginCallbacks {
355382 readonly onSet ?: ( arg : PluginCallbacksOnSetArgument ) => void ;
@@ -360,6 +387,8 @@ export interface PluginCallbacks {
360387/**
361388 * For plugin developers only.
362389 * Hookstate plugin specification and factory method.
390+ *
391+ * [Learn more...](https://hookstate.js.org/docs/writing-plugin)
363392 */
364393export interface Plugin {
365394 /**
@@ -464,6 +493,8 @@ export declare function useState<S>(source: SetInitialStateAction<S>): State<S>;
464493 * It can be also used in class-based React components. It is also
465494 * particularly usefull for creating *scoped* states.
466495 *
496+ * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)
497+ *
467498 * @typeparam S Type of a value of a state
468499 */
469500export declare function StateFragment < S > ( props : {
@@ -474,6 +505,8 @@ export declare function StateFragment<S>(props: {
474505 * Allows to use a state without defining a functional react component.
475506 * See more at [StateFragment](#statefragment)
476507 *
508+ * [Learn more...](https://hookstate.js.org/docs/using-without-statehook)
509+ *
477510 * @typeparam S Type of a value of a state
478511 */
479512export declare function StateFragment < S > ( props : {
@@ -482,18 +515,9 @@ export declare function StateFragment<S>(props: {
482515} ) : React . ReactElement ;
483516/**
484517 * A plugin which allows to opt-out from usage of Javascript proxies for
485- * state usage tracking. It is useful for performance tuning. For example:
486- *
487- * ```tsx
488- * const globalState = createState(someLargeObject as object)
489- * const MyComponent = () => {
490- * const state = useState(globalState)
491- * .with(Downgraded); // the whole state will be used
492- * // by this component, so no point
493- * // to track usage of individual properties
494- * return <>{JSON.stringify(state[self].value)}</>
495- * }
496- * ```
518+ * state usage tracking. It is useful for performance tuning.
519+ *
520+ * [Learn more...](https://hookstate.js.org/docs/performance-managed-rendering#downgraded-plugin)
497521 */
498522export declare function Downgraded ( ) : Plugin ;
499523/**
@@ -525,6 +549,8 @@ export interface DevToolsExtensions {
525549 * for example. If no development tools are activated,
526550 * it returns an instance of dummy tools, which do nothing, when called.
527551 *
552+ * [Learn more...](https://hookstate.js.org/docs/devtools)
553+ *
528554 * @param state A state to relate to the extension.
529555 *
530556 * @returns Interface to interact with the development tools for a given state.
0 commit comments