README
English | 简体中文
Genji
A super-lightweight (core code only 5KB) data state management scheme based on redux and redux-thunk. (Inspired by dva )
竜神の剣を喰らえ! -- shimada genji
Features :new:
- Use namespaces to separate different businesses, and centralize all data processing logic belong to the common namespace in the same place. to facilitate unified data management and provide a pluggable experience for modules.
- Enhanced
actionCreatorofreduxto provide a more friendly data access methods. Users do not need to writereducerrepeatedly. Unified synchronous and asynchronous experience in updatingstate. - The built-in
loadingstate for asynchronous operation makes it easier to get the current operation progress.
Installation :gear:
Assuming you are using npm as your package manager, execute the following command in your project directory:
npm install --save genjijs
If you use yarn, you can also:
yarn add genjijs
Quick Start :beginner:
There is a simple example in this project which used all common features of Genji . Click here to see。
In addition, the following demo may help you become more familiar with Genji :
example-typescript:If you want to have full
Typescriptsupports, refer this.TodoList:A copy of TodoList given by example from
Reduxproject, but useGenjito rewrite.
Q & A :book:
Difference from
dva?
dva is an excellent open source project worldwide, and is also the source of inspiration for this project (this can be seen from the project name). Specially thanks to dva.
In the dva project, redux-saga is used as an asynchronous solution, which makes developers have to use the generator feature to make asynchronous requests, which is different from the mainstream asynchronous invocation methods which used async and Promise , and these may cause some confusion for junior developers. Therefore, in Genji, the redux-thunk written by Dan, the author of Redux, was adopted as our asynchronous solution.
Considering the user habits and functional enhancements brought by redux-saga, we have enhanced the capabilities of redux-thunk by hijack & injection, so that users can define asynchronous function like redux-saga but have supports of async and Promise.
TODO :construction:
- Built-in
loadingstate for asynchronous operation - Added
saveandpickmethods for effects to access state- Create the
reducerasynchronously and inject it into the originalreducer tree - Extend
redux-thunkand hijackdispatch, to extend parameter in - Implement
save&pick - Enhance
save&pick, like get&set from other model or support parsing more parameter types
- Create the
- Add Continuous integration, eslint, and unit test.
- Integrate
reducers&effects - Rewrite
Aciton Type, to support definition jumps & smart tips - A full support of
Typescript - Document