https://github.com/shy2850/ipreact
connect data-actions of preact-components via immutablejs
https://github.com/shy2850/ipreact
Last synced: about 2 months ago
JSON representation
connect data-actions of preact-components via immutablejs
- Host: GitHub
- URL: https://github.com/shy2850/ipreact
- Owner: shy2850
- License: mit
- Created: 2018-03-03T05:05:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-11T08:31:09.000Z (about 6 years ago)
- Last Synced: 2025-03-27T14:55:01.825Z (2 months ago)
- Language: TypeScript
- Size: 131 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IPreact
connect data-actions of preact-componentssee: [ipreact-for-react](https://github.com/shy2850/ipreact-for-react)
## Install
```
npm i ipreact
```## Usage
```tsx
import IPreact from '../src/ipreact'
import { h, Component, render } from 'preact'
const { connect, dispatch, getState } = IPreact()({
name: 'world'
})const AppComponent = ({ words }) =>
{words}
const App = connect(() => ({
words: `hello ${getState().name}!`
}))(AppComponent)let i = 0
setInterval(function () {
const list = ['prect', 'immutable', 'world', 'ipreact']
i = (i + 1) % list.length
dispatch(state => ({name: list[i]}))
}, 1000)
```
