1.0.10 • Published 4 years ago
lit-connect v1.0.10
LIT-CONNECT: Great and simple connect function to connect your components to redux-store
Installation
npm install --save lit-connect
Quick Start
All you have to do is export a connect function using applyConnect on your store
import { applyConnect } from 'lit-connect'
const store = createStore(...));
export const connect = applyConnect(store);
Now you are ready to use the connect function :)
Usage with connect()
lit-connect provides a connect function for you to connect your component to the store.
So now you can:
import { connect } from '<path-of-your-connect>'
import {LitElement, html} from '@polymer/lit-element';
class Test extends LitElement {...}
const mapStateToProps = (state) => {
return {
counter: state.counter
}
}
const mapDispatchToProps = dispatch => {
return {
onInit: () => dispatch(action)
}
}
export default () =>
customElements.define('test', connect(mapStateToProps, mapDispatchToProps)(Test));
// Name of the custom html element that should be defined
Every property returned from mapStateToProps() and mapDisptachToProps() is now added to the class properties and as soon as you change the state LitElement automatically re-renders the component.
Feel free to contact me at: boninsegna.omar@gmail.com for every concern