https://github.com/maxmellon/hydreducer
A library is provide the reducer for Selective Hydration based on react hooks.
https://github.com/maxmellon/hydreducer
Last synced: 4 months ago
JSON representation
A library is provide the reducer for Selective Hydration based on react hooks.
- Host: GitHub
- URL: https://github.com/maxmellon/hydreducer
- Owner: MaxMEllon
- License: mit
- Created: 2019-10-26T13:13:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T11:05:57.000Z (over 3 years ago)
- Last Synced: 2025-10-19T20:44:07.265Z (8 months ago)
- Language: TypeScript
- Homepage:
- Size: 2.26 MB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 56
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# About
- type-safe redux and support ducks pattern.
*This module is development now*
# Feature
## Multi store (store instance created each module.)
- Want to hydarate each by module from server.
- In redux case, that have to do chunking a store state, because that is a single state.
- That's a incompatible the state chunking and streaming rendering.
## Minimum type definition
- This module is providing to infer types of state, actions, and reducer.
- You have not to do define types.
- Just define object it.
## Other
- tiny
- universal (isomorphic)
# Example
```typescript
const [actions, Provider, useAction, useModuleState] = createModule
.initialState({
count: 0
})
.actions({
setCount: createAction("count/set"),
increment: createAction("count/inc"),
decrement: createAction("count/dec"),
})
.reducer((actions, reducer) => (
reducer
.case(actions.setCount, (state, payload) => ({
...state,
count: payload
})
.case(actions.increment, (state) => ({
...state,
count: state.count + 1
}))
.case(actions.decrement, (state) => ({
...state,
count: state.count - 1
}))
))
.build()
// original API (like as useDispatch + useCallback)
const increment = useAction(() => actions.increment())
// like `useSelector` in react-redux
const count = useModuleState(state => state.count)
```
# Inspired
- [typeless](https://github.com/typeless-js/typeless)
- [typescript-fsa](https://github.com/aikoven/typescript-fsa)
- [typescript-fsa-reducers](https://github.com/dphilipson/typescript-fsa-reducers)
- [mobx-state-tree](https://github.com/mobxjs/mobx-state-tree)
# TODO
- [ ] testing
- [ ] Promise or Rx or other anything.
- [ ] approach to hydrate from server with React.
# LICENSE
MIT