mobx-react-use-autorun 1.0.13 → 1.0.14
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 +30 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,6 +105,36 @@ Form validation<br/>
|
|
|
105
105
|
</div>
|
|
106
106
|
})
|
|
107
107
|
|
|
108
|
+
## Notes - Ignore frequent asynchronous calls with useAsyncExhaust
|
|
109
|
+
|
|
110
|
+
import { TextField } from "@mui/material";
|
|
111
|
+
import { useLocalObservable, observer, useAsyncExhaust } from 'mobx-react-use-autorun';
|
|
112
|
+
import axios from 'axios';
|
|
113
|
+
|
|
114
|
+
export default observer(() => {
|
|
115
|
+
|
|
116
|
+
const state = useLocalObservable(() => ({
|
|
117
|
+
list: [],
|
|
118
|
+
searchText: ""
|
|
119
|
+
}));
|
|
120
|
+
|
|
121
|
+
const search = useAsyncExhaust(async () => {
|
|
122
|
+
state.list = await axios.get("/search");
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<TextField
|
|
127
|
+
label="Please enter search content"
|
|
128
|
+
variant="outlined"
|
|
129
|
+
value={state.searchText}
|
|
130
|
+
onChange={(e) => {
|
|
131
|
+
state.searchText = e.target.value;
|
|
132
|
+
search();
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
);
|
|
136
|
+
})
|
|
137
|
+
|
|
108
138
|
## Notes - Define global mutable data
|
|
109
139
|
|
|
110
140
|
import { observable } from 'mobx-react-use-autorun';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-react-use-autorun",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "React Hook for mobx",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm install -g typescript@4.6.3 @types/node@17.0.23 ts-node@10.7.0 cross-env@7.0.3 && cross-env TS_NODE_SKIP_PROJECT=true ts-node bin/mobx_react_build.ts",
|