reaxes-toolkit 1.0.2 → 1.0.4
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 +8 -1
- package/package.json +2 -1
- package/readme.md +6 -10
package/changelog.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
# 1.0.
|
|
1
|
+
# 1.0.4
|
|
2
|
+
* License added
|
|
3
|
+
# 1.0.3
|
|
4
|
+
* doc fixed & optimized
|
|
5
|
+
# 1.0.1
|
|
6
|
+
* doc optimized
|
|
7
|
+
|
|
8
|
+
# 1.0.0
|
|
2
9
|
* 将orzImport转移至reaxes-utils中并改名为xImport
|
|
3
10
|
* 将orzPending改名为rexaStatus , 并且所有toolkit函数统一使用rexa作为前缀
|
|
4
11
|
* 清理了rexaStatus冗余的异步逻辑,现在已改为同步修改store
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "reaxes-toolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Toolkit Based on `reaxes`",
|
|
5
5
|
"main": "esm/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
7
|
+
"license": "WTFPL",
|
|
7
8
|
"types": "types/index.d.ts",
|
|
8
9
|
"dependencies": {
|
|
9
10
|
"reaxes": "^1.1.0",
|
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
|
|