Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tjdavies/hyper-redux
hyper app style redux react
https://github.com/tjdavies/hyper-redux
Last synced: about 1 month ago
JSON representation
hyper app style redux react
- Host: GitHub
- URL: https://github.com/tjdavies/hyper-redux
- Owner: tjdavies
- Created: 2018-04-13T13:11:11.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-17T09:39:43.000Z (about 6 years ago)
- Last Synced: 2024-10-31T19:41:57.845Z (about 1 month ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-star - hyper-redux
README
## hyper-redux
HyperApp style redux
For those who need to use react and redux but want something simple
- No more switch statments or action objects
- Fully supports redux debugger with time travel ect.
- Can be strongly typed with TypeScript
- Can use context to access state and actions in nested components## Install
```sh
npm install hyper-redux
```
## Example```js
import * as React from 'react';
import { app } from 'hyper-redux';const initalState: 0;
const actionsMap = {
increment: delta => state => state + delta,
decrement: delta => state => state - delta,
incrementDelayed: delta => (state, actions) => {
setTimeout(actions.increment, 1000, delta);
return state;
}
};function view(state, actions ) {
return (
Clicked: {state} times
actions.increment(1)}>+
actions.decrement(1)}>-
actions.incrementDelayed(1)}>+ delayed
);
}app(initalState, actionsMap, view, document.body);
```## Live Demo
[![Edit hyper-redux example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/745pqpnoz6)