@hookstate/core
Advanced tools
Comparing version
@@ -143,3 +143,10 @@ import React from 'react'; | ||
readonly value: S; | ||
/** | ||
* True if state value is not yet available (eg. equal to a promise) | ||
*/ | ||
readonly promised: boolean; | ||
/** | ||
* If a state was set to a promise and the promise was rejected, | ||
* this property will return the error captured from the promise rejection | ||
*/ | ||
readonly error: StateErrorAtRoot | undefined; | ||
@@ -180,20 +187,22 @@ /** | ||
merge(newValue: SetPartialStateAction<S>): void; | ||
/** | ||
* Returns nested state by key. | ||
* `state.nested('myprop')` returns the same as `state.myprop` or `state['myprop']`, | ||
* but also works for properties, which names collide with names of state methods. | ||
* | ||
* [Learn more about nested states...](https://hookstate.js.org/docs/nested-state) | ||
* | ||
* @param key child property name or index | ||
*/ | ||
nested<K extends keyof S>(key: K): State<S[K]>; | ||
/** | ||
* Maps this state to the result via the provided action. | ||
* Runs the provided action callback with optimised re-rendering. | ||
* Updating state within a batch action does not trigger immediate rerendering. | ||
* Instead, all required rerendering is done once the batch is finished. | ||
* | ||
* @param action mapper function | ||
* [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates | ||
* | ||
* @param onPromised this will be invoked instead of the action function, | ||
* if a state value is unresolved promise. | ||
* [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state) | ||
* @param action callback function to execute in a batch | ||
* | ||
* @param onError this will be invoked instead of the action function, | ||
* if a state value is a promise resolved to an error. | ||
* [Learn more about async states...](https://hookstate.js.org/docs/asynchronous-state) | ||
* | ||
* @param context if specified, the callbacks will be invoked in a batch. | ||
* Updating state within a batch does not trigger immediate rerendering. | ||
* Instead, all required rerendering is done once once the batch is finished. | ||
* [Learn more about batching...](https://hookstate.js.org/docs/performance-batched-updates | ||
* @param context custom user's value, which is passed to plugins | ||
*/ | ||
@@ -200,0 +209,0 @@ batch<R, C>(action: (s: State<S>) => R, context?: Exclude<C, Function>): R; |
@@ -32,4 +32,2 @@ import React from 'react'; | ||
// TODO move to internal | ||
var self = Symbol('self'); | ||
/** | ||
@@ -166,2 +164,3 @@ * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function. | ||
/// | ||
var self = Symbol('self'); | ||
var EmptyDevToolsExtensions = { | ||
@@ -168,0 +167,0 @@ label: function () { }, |
@@ -38,4 +38,2 @@ 'use strict'; | ||
// TODO move to internal | ||
var self = Symbol('self'); | ||
/** | ||
@@ -172,2 +170,3 @@ * Special symbol which might be returned by onPromised callback of [StateMethods.map](#map) function. | ||
/// | ||
var self = Symbol('self'); | ||
var EmptyDevToolsExtensions = { | ||
@@ -174,0 +173,0 @@ label: function () { }, |
{ | ||
"name": "@hookstate/core", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "The flexible, fast and extendable state management for React that is based on hooks and state usage tracking.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
316980
0.12%2731
0.26%