# pri-plugin-rematch

> pri plugin for rematch

Latest version **3.0.0** (published 2019-05-06) · ISC license · 0 weekly downloads

## Install

```sh
npm install pri-plugin-rematch
pnpm add pri-plugin-rematch
yarn add pri-plugin-rematch
bun add pri-plugin-rematch
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2019-05-06 |
| First published | 2018-05-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | ascoders |

## Links

- npm: https://www.npmjs.com/package/pri-plugin-rematch
- Repository: https://github.com/prijs/pri-plugin-rematch
- Homepage: https://github.com/prijs/pri-plugin-rematch#readme
- Issues: https://github.com/prijs/pri-plugin-rematch/issues
- npm.io page: https://npm.io/package/pri-plugin-rematch

## Dependencies (4)

- [react-redux](https://npm.io/package/react-redux.md) ^5.0.7
- [@rematch/core](https://npm.io/package/@rematch/core.md) ^1.1.0
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.0.0
- [@types/react-redux](https://npm.io/package/@types/react-redux.md) ^6.0.0

## Recent versions

- 3.0.0 (latest) — 2019-05-06
- 2.0.1 — 2019-04-26
- 2.0.0 — 2019-02-03
- 1.0.13 — 2019-01-01
- 1.0.12 — 2018-12-13
- 1.0.11 — 2018-08-13
- 1.0.9 — 2018-08-13
- 1.0.8 — 2018-08-04
- 1.0.7 — 2018-07-23
- 1.0.6 — 2018-07-12
- 1.0.5 — 2018-06-24
- 1.0.4 — 2018-06-10
- 1.0.3 — 2018-05-13
- 1.0.2 — 2018-05-13
- 1.0.1 — 2018-05-13
- … 1 more at https://npm.io/package/pri-plugin-rematch/versions

## README

# pri-plugin-rematch &middot; [![npm version](https://img.shields.io/npm/v/pri-plugin-rematch.svg?style=flat-square)](https://www.npmjs.com/package/pri-plugin-rematch)

[rematch](https://github.com/rematch/rematch) is a nice framework for redux.

We provide `pri-plugin-rematch` to use it more easy!

## Usage

```bash
npm i pri-plugin-rematch
```

```
.
├── src
│    └── models
│          ├── application.ts      # model file
│          └── user.ts             # model file
└── priconfig.json
```

Let’s try it! For example, create a model named `user`:

**src/models/user.ts**

```typescript
import { model } from 'pri/model';

export default model({
  state: {
    name: 'jeck',
    age: 25
  },
  reducers: {
    increment: (state, count = 1) => {
      return {
        ...state,
        age: state.age + count
      };
    }
  },
  effects: {
    async asyncIncrement() {
      await new Promise(resolve => {
        setTimeout(resolve, 1000);
      });
      this.increment(5);
    }
  }
});
```

Then, use it in pages!

**src/pages/index.tsx**

```typescript
import { connect } from 'pri/models';

@connect(
  state => {
    return {
      age: state.user.age
    };
  },
  dispatch => {
    return { increment: dispatch.user.increment, asyncIncrement: dispatch.user.asyncIncrement };
  }
)
export default class Page extends React.PureComponent<Props, State> {
  /**/
}
```

> Import connect from 'pri/models' is a better way, 'pri/models' provides a strong typed `connect` function:

<img src="https://user-images.githubusercontent.com/7970947/39965212-62615908-56c7-11e8-9084-081734eaf280.png" width={400} />

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