# seamless-redux

> `React` should render DOM elements, and `Redux` should handle state management - easy to say, hard to do. `seamless-redux` facilitate the separation between `React` and `Redux` by eliminating the `dispatch` method and the overhead of writing repetitive co

Latest version **1.0.9** (published 2019-09-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install seamless-redux
pnpm add seamless-redux
yarn add seamless-redux
bun add seamless-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.9 |
| Published | 2019-09-05 |
| First published | 2019-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 2.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | bnbarak |
| Maintainers | bnbarak |

## Links

- npm: https://www.npmjs.com/package/seamless-redux
- Homepage: https://github.com/bnbarak/seamless-redux
- npm.io page: https://npm.io/package/seamless-redux

## Dependencies (5)

- [redux](https://npm.io/package/redux.md) ^4.0.4
- [lodash](https://npm.io/package/lodash.md) ^4.17.14
- [reselect](https://npm.io/package/reselect.md) ^4.0.0
- [keymirror](https://npm.io/package/keymirror.md) ^0.1.1
- [redux-thunk](https://npm.io/package/redux-thunk.md) ^2.3.0

## Recent versions

- 1.0.9 (latest) — 2019-09-05
- 1.0.8 — 2019-09-05
- 1.0.7 — 2019-09-05
- 1.0.6 — 2019-09-04
- 1.0.5 — 2019-09-02
- 1.0.4 — 2019-09-02
- 1.0.3 — 2019-08-19
- 1.0.2 — 2019-08-12
- 1.0.1 — 2019-07-23
- 1.0.0 — 2019-07-23

## README

# Motivation

`React` should render DOM elements, and `Redux` should handle state management - easy to say, hard to do.
`seamless-redux` facilitate the separation between `React` and `Redux` by eliminating the `dispatch` method and the overhead of writing repetitive code.

To improve  React/Redux architecture, `seamless-redux` created decorators for common *actions/reducers/selectors* to better handle state management for loading state, data state, and error state.

* **Yes**, `seamless-redux` is using [reselect](https://github.com/reduxjs/reselect) by default
* **Yes**, `seamless-redux` and can be integrated to an exciting store
* **No**, `seamless-redux` is not a breaking change
</aside>

# Install
`npm install seamless-redux`

# Documentation
[seamless-redux](https://bnbarak.github.io/seamless-redux) documentations

Live Example

[![Edit seamless-redux example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/react-example-2q9be?fontsize=14)
# Example

> Entity

Creating an entity will initiate the data, loading, and error states.

```jsx
seamless.createEntity("User", {});
```


> React Component

```jsx
import React from 'react';
import { selectors } from 'seamless-redux';

const {
  selectData, selectLoading, selectIsError, selectErrorData,
} = selectors;


class MyComponent extends React.PureComponent {
  componentDidMount() {
    authUserAction(email, password);
  }
 
  render() {
    const { isLoading, isError, errorMessage, user } = this.props;
    return <div />
  }
}
```

> selectors

```jsx
const mapStateToProps = state => ({
  isLoading: selectLoading(state, "MyEntity"),
  isError: selectIsError(state, "MyEntity"),
  errorMessage: selectErrorData(state, "MyEntity"),
  user: selectData(state, "MyEntity"),
});

export default connect(
  mapStateToProps,
  null
)(MyComponent);
```

> Action

```jsx
export const authUserAction = (email, password) => {
  const userEntity = seamless.getEntity("User");
  userEntity.start();
  userEntity.resetError();
  // Or userEntity.reset();

  authApi(email, password)
    .then((response) => userEntity.newData(response.data))
    .catch(() => userEntity.newError("Error auth"))
    .finally(() => userEntity.finish());
};
```

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