lit-redux
v1.0.3
Published
`lit-redux` is implementation of [`react-redux` API](https://github.com/reactjs/react-redux) for [`lit-html`](https://github.com/PolymerLabs/lit-html) library.
Downloads
22
Readme
lit-redux
lit-redux
is implementation of react-redux
API for lit-html
library.
Example
import {html, render} from 'lit-html/lib/lit-extended';
import {connect} from 'lit-redux';
import {createStore, bindActionCreators} from 'redux';
const todos = (state = [], action) => {
switch (action.type) {
case 'ADD_TODO':
return state.concat([action.text]);
default:
return state;
}
};
const store = createStore(todos, ['Use Redux']);
const actions = {
add() {
return {
type: 'ADD_TODO',
text: `Hello ${Math.random()}`
};
},
};
const todosView = connect(
state => ({ todos: state }),
dispatch => ({ actions: bindActionCreators(actions, dispatch) })
)(({todos, actions}) => html`
${ todos.map(text => html`<p>${ text }</p>`) }
<button type="button" onclick="${ () => actions.add() }">Add</button>
`);
render(
html`${ todosView({ store }) }`,
document.body
);
Current progress
- Implemented
connect()
function (onlystoreKey
option is available)
Other related projects
lit-form
- Formik API implementation forlit-html
library