English | 简体中文
A super-lightweight (core code only 5KB) data state management scheme based on redux
and redux-thunk
. (Inspired by dva )
竜神の剣を喰らえ! -- shimada genji
- 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
actionCreator
ofredux
to provide a more friendly data access methods. Users do not need to writereducer
repeatedly. Unified synchronous and asynchronous experience in updatingstate
. - The built-in
loading
state for asynchronous operation makes it easier to get the current operation progress.
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
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
Typescript
supports, refer this. -
TodoList:A copy of TodoList given by example from
Redux
project, but useGenji
to rewrite.
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
.
- Built-in
loading
state for asynchronous operation - Added
save
andpick
methods for effects to access state- Create the
reducer
asynchronously and inject it into the originalreducer tree
- Extend
redux-thunk
and 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