ipreact
Version:
connect data-actions of preact-components via immutablejs
20 lines • 610 B
JavaScript
import createStore from '../src/ipreact';
import { h, render } from 'preact';
const { connect, dispatch, getState } = createStore()({
name: 'world'
});
const AppComponent = ({ words }) => h("h2", null, words);
const connectApp = connect;
const App = connectApp(() => ({
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);
export default ({ el }) => {
render(h(App, null), el);
};
//# sourceMappingURL=index.js.map