miracle-observer
Push-based Data & Event management based on React Hooks and RxJS
Install
npm i miracle-observer
https://www.npmjs.com/package/miracle-observer
Usage
// init store all in one file or multifiles; ; ; // create notify instance, you can have multi stations in anywhereconst station = ; const sub1 = ; /** * 订阅方法 * @param key Event Key * @param cbGetState Callback * @param matchType SubscribeMatchType * @param period time that has to pass before emiting new items (ms) * @param throttle 0 for throttleTime * 1 for debounceTime * @param preprocessing data pre process**/ const sub2 = ; station;station; ;
Use with React Hook
;; const App: => { const globalCount setGlobalCount = ; // bind every rerender, globalCount is fresh ; // bind once in Component Mount, globalCount will not change ; ...
Use with Ajax
npm install axios
axios ;
Reference
https://github.com/ReactiveX/RxJS
https://reactjs.org/docs/hooks-effect.html
https://cn.rx.js.org/manual/index.html
https://cn.rx.js.org/class/es6/Observable.js~Observable.html
https://www.jianshu.com/p/76901410645a
https://github.com/LeetCode-OpenSource/rxjs-hooks
https://github.com/LeetCode-OpenSource/rxjs-hooks
https://zhuanlan.zhihu.com/p/49408348
https://github.com/react-native-community/hooks