@t8/react-pending 1.0.30 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # T8 React Pending
2
2
 
3
- *Concise async action state tracking for React apps*
3
+ A concise async action state management lib for React apps
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@t8/react-pending?labelColor=345&color=46e)](https://www.npmjs.com/package/@t8/react-pending) ![Lightweight](https://img.shields.io/bundlephobia/minzip/@t8/react-pending?label=minzip&labelColor=345&color=46e) ![CSR ✓](https://img.shields.io/badge/CSR-✓-345?labelColor=345) ![SSR ✓](https://img.shields.io/badge/SSR-✓-345?labelColor=345)
6
6
 
@@ -70,9 +70,9 @@ In our setup, there are two components rendering their content with regard to th
70
70
 
71
71
  [Live demo](https://codesandbox.io/p/sandbox/rrr9cl?file=%2Fsrc%2FItemList.tsx)
72
72
 
73
- 🔹 To share the async action's pending state with multiple components we're using the string key parameter of `usePendingState(stateKey)`. This key can be used with `usePendingState(stateKey)` in other components to refer to the same pending state (as in the `Status` component above), so `stateKey` should be unique to the particular pending state.
73
+ To share the async action's pending state with multiple components we're using the string key parameter of `usePendingState(stateKey)`. This key can be used with `usePendingState(stateKey)` in other components to refer to the same pending state (as in the `Status` component above), so `stateKey` should be unique to the particular pending state.
74
74
 
75
- 🔹 In the example above, the data returned from the async action is stored in the component's local state, but it can be stored in any app state of the developer's choice without affecting how the `usePendingState()` hook is used.
75
+ In the example above, the data returned from the async action is stored in the component's local state, but it can be stored in any app state of the developer's choice without affecting how the `usePendingState()` hook is used.
76
76
 
77
77
  ## Local pending state
78
78
 
@@ -90,7 +90,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
90
90
  + withState(fetchItems(), { silent: true })
91
91
  ```
92
92
 
93
- 🔹 This option prevents `state.complete` from switching to `false` in the pending state.
93
+ This option prevents `state.complete` from switching to `false` in the pending state.
94
94
 
95
95
  ## Delayed pending state
96
96
 
@@ -99,7 +99,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
99
99
  + withState(fetchItems(), { delay: 500 }) // in milliseconds
100
100
  ```
101
101
 
102
- 🔹 Use case: avoiding flashing a process indicator when the action is likely to complete by the end of a short delay.
102
+ Use case: avoiding flashing a process indicator when the action is likely to complete by the end of a short delay.
103
103
 
104
104
  ## Custom rejection handler
105
105
 
@@ -108,7 +108,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
108
108
  + withState(fetchItems(), { throws: true }).catch(handleError)
109
109
  ```
110
110
 
111
- 🔹 This option allows the async action to reject explicitly, along with exposing `state.error` that goes by default.
111
+ This option allows the async action to reject explicitly, along with exposing `state.error` that goes by default.
112
112
 
113
113
  ## Providing blank initial pending state
114
114
 
@@ -121,7 +121,7 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
121
121
  + </PendingStateProvider>
122
122
  ```
123
123
 
124
- 🔹 `<PendingStateProvider>` creates an isolated instance of initial shared action state. Prime use cases are SSR and tests. It isn't required with client-side rendering, but it can be used to separate action states of larger self-contained portions of a web app.
124
+ `<PendingStateProvider>` creates an isolated instance of initial shared action state. Its prime use cases are SSR and tests. It isn't required with client-side rendering, but it can be used to separate action states of larger self-contained portions of an app.
125
125
 
126
126
  ## Providing custom initial pending&nbsp;state
127
127
 
@@ -136,6 +136,6 @@ Omit the custom string key parameter of `usePendingState()` to scope the pending
136
136
  </PendingStateProvider>
137
137
  ```
138
138
 
139
- 🔹 While fully optional, this setup allows to override the initial state received from `usePendingState(stateKey)`.
139
+ While fully optional, this setup allows to redefine the initial state received from `usePendingState(stateKey)`.
140
140
 
141
- 🔹 With an explicit value or without, the `<PendingStateProvider>`'s nested components will only respond to updates in the particular action states they subscribed to by means of `usePendingState(stateKey)`.
141
+ With an explicit value or without, the `<PendingStateProvider>`'s nested components will only respond to updates in the particular action states they subscribed to by means of `usePendingState(stateKey)`.
package/dist/index.cjs CHANGED
@@ -37,8 +37,8 @@ function createState(initialized = false, complete = false, error) {
37
37
  * - `state` is the current value of the action's state;
38
38
  * - `withState(action, options?)` reads and tracks the `actions`'s state
39
39
  * which is exposed as `state` listed above;
40
- * - `setState(update)` can replace the current `state` value directly with
41
- * an another state value.
40
+ * - `setState(update)` can be used to replace the current `state` value
41
+ * directly with an another state value.
42
42
  */
43
43
  function usePendingState(store) {
44
44
  let storeMap = (0, react.useContext)(PendingStateContext);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react0 from "react";
2
2
  import { ReactNode } from "react";
3
- import { SetStoreState, Store } from "@t8/react-store";
3
+ import { SetStoreValue, Store } from "@t8/react-store";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
 
6
6
  type PendingState = {
@@ -55,9 +55,9 @@ type WithStateOptions = {
55
55
  * - `state` is the current value of the action's state;
56
56
  * - `withState(action, options?)` reads and tracks the `actions`'s state
57
57
  * which is exposed as `state` listed above;
58
- * - `setState(update)` can replace the current `state` value directly with
59
- * an another state value.
58
+ * - `setState(update)` can be used to replace the current `state` value
59
+ * directly with an another state value.
60
60
  */
61
- declare function usePendingState(store?: string | Store<PendingState> | null): [PendingState, <T>(value: T) => T, SetStoreState<PendingState>];
61
+ declare function usePendingState(store?: string | Store<PendingState> | null): [PendingState, <T>(value: T) => T, SetStoreValue<PendingState>];
62
62
 
63
63
  export { PendingState, PendingStateContext, PendingStateProvider, PendingStateProviderProps, WithStateOptions, usePendingState };
package/dist/index.mjs CHANGED
@@ -37,8 +37,8 @@ function createState(initialized = false, complete = false, error) {
37
37
  * - `state` is the current value of the action's state;
38
38
  * - `withState(action, options?)` reads and tracks the `actions`'s state
39
39
  * which is exposed as `state` listed above;
40
- * - `setState(update)` can replace the current `state` value directly with
41
- * an another state value.
40
+ * - `setState(update)` can be used to replace the current `state` value
41
+ * directly with an another state value.
42
42
  */
43
43
  function usePendingState(store) {
44
44
  let storeMap = useContext(PendingStateContext);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@t8/react-pending",
3
- "version": "1.0.30",
4
- "description": "Concise async action state tracking for React apps",
3
+ "version": "1.0.31",
4
+ "description": "A concise async action state management lib for React apps",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -29,13 +29,13 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "@playwright/test": "^1.56.0",
32
- "@t8/serve": "^0.1.38",
32
+ "@t8/serve": "^0.1.39",
33
33
  "@types/node": "^24.10.2",
34
34
  "@types/react": "^19.2.7",
35
35
  "@types/react-dom": "^19.2.3",
36
- "react-dom": "^19.2.1"
36
+ "react-dom": "^19.2.3"
37
37
  },
38
38
  "dependencies": {
39
- "@t8/react-store": "^1.2.6"
39
+ "@t8/react-store": "^1.2.7"
40
40
  }
41
41
  }
@@ -1,4 +1,4 @@
1
- import { isStore, type SetStoreState, Store, useStore } from "@t8/react-store";
1
+ import { isStore, type SetStoreValue, Store, useStore } from "@t8/react-store";
2
2
  import { useCallback, useContext, useMemo, useRef, useState } from "react";
3
3
  import type { PendingState } from "./PendingState.ts";
4
4
  import { PendingStateContext } from "./PendingStateContext.ts";
@@ -51,12 +51,12 @@ export type WithStateOptions = {
51
51
  * - `state` is the current value of the action's state;
52
52
  * - `withState(action, options?)` reads and tracks the `actions`'s state
53
53
  * which is exposed as `state` listed above;
54
- * - `setState(update)` can replace the current `state` value directly with
55
- * an another state value.
54
+ * - `setState(update)` can be used to replace the current `state` value
55
+ * directly with an another state value.
56
56
  */
57
57
  export function usePendingState(
58
58
  store?: string | Store<PendingState> | null,
59
- ): [PendingState, <T>(value: T) => T, SetStoreState<PendingState>] {
59
+ ): [PendingState, <T>(value: T) => T, SetStoreValue<PendingState>] {
60
60
  let storeMap = useContext(PendingStateContext);
61
61
  let storeRef = useRef<Store<PendingState> | null>(null);
62
62
  let [storeItemInited, setStoreItemInited] = useState(false);