mobx-react-use-autorun 3.0.33 → 3.0.34
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 +26 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -173,7 +173,14 @@ Other than that, all usages are correct. Example:<br/>
|
|
|
173
173
|
|
|
174
174
|
import { observable } from 'mobx-react-use-autorun';
|
|
175
175
|
|
|
176
|
-
const
|
|
176
|
+
export const globalState = observable({
|
|
177
|
+
age: 15
|
|
178
|
+
name: 'tom'
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
export async function setName(name: string){
|
|
182
|
+
globalState.name = name
|
|
183
|
+
}
|
|
177
184
|
|
|
178
185
|
## Introduction to third-party hooks
|
|
179
186
|
|
|
@@ -182,22 +189,27 @@ useUnmount is executed when the component is unmount.<br/>
|
|
|
182
189
|
|
|
183
190
|
import { useMount, useUnmount } from 'react-use'
|
|
184
191
|
import { Subscription, of, tap } from 'rxjs'
|
|
185
|
-
import { useMobxState } from 'mobx-react-use-autorun'
|
|
192
|
+
import { useMobxState, observer } from 'mobx-react-use-autorun'
|
|
186
193
|
|
|
187
|
-
|
|
188
|
-
subscription: new Subscription()
|
|
189
|
-
})
|
|
194
|
+
export default observer(() => {
|
|
190
195
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
console.log('component is loaded')
|
|
195
|
-
})
|
|
196
|
-
).subscribe())
|
|
197
|
-
})
|
|
196
|
+
const state = useMobxState({
|
|
197
|
+
subscription: new Subscription()
|
|
198
|
+
})
|
|
198
199
|
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
useMount(() => {
|
|
201
|
+
state.subscription.add(of(null).pipe(
|
|
202
|
+
tap(() => {
|
|
203
|
+
console.log('component is loaded')
|
|
204
|
+
})
|
|
205
|
+
).subscribe())
|
|
206
|
+
})
|
|
207
|
+
|
|
208
|
+
useUnmount(() => {
|
|
209
|
+
state.subscription.unsubscribe()
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
return null;
|
|
201
213
|
})
|
|
202
214
|
|
|
203
215
|
## Learn More
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"mobx-react-use-autorun","version":"3.0.
|
|
1
|
+
{"name":"mobx-react-use-autorun","version":"3.0.34","description":"React Hook for mobx","scripts":{"test":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_test.ts","build":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_build.ts","make":"npx -y -p typescript -p ts-node ts-node --skipProject bin/mobx_react_make.ts"},"dependencies":{"mobx":">=6.5.0","mobx-react-lite":">=3.3.0","react-use":">=17.3.2","rxjs":">=6.0.0"},"peerDependencies":{"react":">=16.8.0"},"license":"MIT","keywords":["react","mobx","typescript"],"main":"./dist/index.js","types":"./dist/index.d.ts","eslintConfig":{"extends":["react-app","react-app/jest"]},"homepage":"https://github.com/zdu-strong/mobx-react-use-autorun#readme","repository":{"type":"git","url":"git+https://github.com/zdu-strong/mobx-react-use-autorun.git"},"files":["lib","dist"],"bugs":{"url":"https://github.com/zdu-strong/mobx-react-use-autorun/issues"},"publishConfig":{"registry":"https://registry.npmjs.org/"}}
|