reaxes-toolkit 1.0.2 → 1.0.3
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/changelog.md +6 -1
- package/package.json +1 -1
- package/readme.md +6 -10
package/changelog.md
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -19,8 +19,8 @@ $ npm i -S reaxes-toolkit
|
|
|
19
19
|
|
|
20
20
|
### 🛠 在 `reaxel` 中使用
|
|
21
21
|
```tsx
|
|
22
|
-
import { rexaStatus } from 'reaxes-toolkit';
|
|
23
22
|
//reaxels/user-bio.ts
|
|
23
|
+
import { rexaStatus } from 'reaxes-toolkit';
|
|
24
24
|
export const reaxel_UserBio = reaxel(() => {
|
|
25
25
|
const { status,setStatus } = rexaStatus();
|
|
26
26
|
const { store , setState , mutate } = createReaxable({
|
|
@@ -83,29 +83,25 @@ export default reaxper(() => {
|
|
|
83
83
|
### 🏗 纯 `React` 示例
|
|
84
84
|
```tsx
|
|
85
85
|
const Test = reaxper(() => {
|
|
86
|
-
const { current : {
|
|
87
|
-
pendingState,
|
|
88
|
-
setError,
|
|
89
|
-
setPending
|
|
90
|
-
} } = useRef(rexaStatus());
|
|
86
|
+
const { current : { status,setStatus } } = useRef(rexaStatus());
|
|
91
87
|
const [ data , setData ] = useState(null);
|
|
92
88
|
|
|
93
89
|
useEffect(() => {
|
|
94
90
|
fetch(`api.com`).
|
|
95
91
|
then(( data ) => {
|
|
96
92
|
setData(data);
|
|
97
|
-
|
|
93
|
+
setStatus({pending:false});
|
|
98
94
|
}).
|
|
99
95
|
catch(e => {
|
|
100
|
-
|
|
96
|
+
setStatus({pending:false,error:e});
|
|
101
97
|
});
|
|
102
98
|
},[]);
|
|
103
99
|
|
|
104
|
-
if(
|
|
100
|
+
if( status.pending ) {
|
|
105
101
|
return <div>pending...</div>;
|
|
106
102
|
}
|
|
107
103
|
|
|
108
|
-
if(
|
|
104
|
+
if( status.error ) {
|
|
109
105
|
return <div>Error!</div>;
|
|
110
106
|
}
|
|
111
107
|
|