# lit-redux

> `lit-redux` is implementation of [`react-redux` API](https://github.com/reactjs/react-redux) for [`lit-html`](https://github.com/PolymerLabs/lit-html) library.

Latest version **1.0.3** (published 2017-11-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install lit-redux
pnpm add lit-redux
yarn add lit-redux
bun add lit-redux
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-11-11 |
| First published | 2017-11-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jmas |

## Links

- npm: https://www.npmjs.com/package/lit-redux
- npm.io page: https://npm.io/package/lit-redux

## Dependencies (1)

- [lit-html](https://npm.io/package/lit-html.md) ^0.7.1

## Recent versions

- 1.0.3 (latest) — 2017-11-11
- 1.0.2 — 2017-11-10
- 1.0.1 — 2017-11-10
- 1.0.0 — 2017-11-09

## README

# `lit-redux`

`lit-redux` is implementation of [`react-redux` API](https://github.com/reactjs/react-redux) for [`lit-html`](https://github.com/PolymerLabs/lit-html) library.

## Example

```js
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
);
```

[Live Demo](https://codepen.io/alex_maslakov/pen/RjKJNo?editors=1000)

## Current progress

* Implemented `connect()` function (only `storeKey` option is available)

## Other related projects

* [`lit-form`](https://github.com/jmas/lit-form) - Formik API implementation for `lit-html` library

---
_Source: https://npm.io/package/lit-redux · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
