nanodux
所属分类:GPT/ChatGPT
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2017-09-22 12:45:09
上 传 者:
sh-1993
说明: 一个微型的redux库,内置thunk,用于娱乐原型
(A tiny redux library with thunk built in - for fun prototypes)
文件列表:
dist/ (0, 2017-09-22)
dist/bundle.cjs.js (1953, 2017-09-22)
dist/bundle.es.js (1820, 2017-09-22)
dist/bundle.umd.js (2232, 2017-09-22)
index.js (1037, 2017-09-22)
package.json (831, 2017-09-22)
rollup.config.js (317, 2017-09-22)
test/ (0, 2017-09-22)
test/combine_test.js (860, 2017-09-22)
test/index_test.js (831, 2017-09-22)
yarn.lock (64860, 2017-09-22)
# nanodux
A tiny implementation of a redux like api.
This light version of redux comes with thunk built-in to dispatch, there is not concept of middleware, it simply provides a createStore method that creates an object which has the `dispatch`, `subscribe`, and `getState` methods.
You also have the helper combineReducers to make it easy to build out a global state tree.
## Install
`yarn add nanodux`
## Usage
``` js
import { createStore, combineReducers } from 'nanodux'
const store = createStore(
combineReducers({
counter: (state=0, action) => {
switch (action.type) {
case 'INCR':
return state + action.payload
default:
return state
}
}
})
)
store.subscribe((state, prevState) => {
console.log('state changed')
})
store.dispatch({type: 'INCR', payload: 1})
```
## Test
`yarn test`
## License
MIT
## Thank you
* Redux Community
---
DISCLAIMER: this module is only recommended for prototyping and learning, it is not battle tested for production systems, use Redux for that!
近期下载者:
相关文件:
收藏者: