# wx-reactive

> 微信小程序状态管理插件

Latest version **1.2.0** (published 2021-05-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install wx-reactive
pnpm add wx-reactive
yarn add wx-reactive
bun add wx-reactive
```

## 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.2.0 |
| Published | 2021-05-21 |
| First published | 2021-05-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 34.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | huzedong2008@vip.qq.com |
| Maintainers | huzedong2021 |

## Links

- npm: https://www.npmjs.com/package/wx-reactive
- Repository: https://github.com/huzedong2015/wx-reactive
- Homepage: https://github.com/huzedong2015/wx-reactive#readme
- Issues: https://github.com/huzedong2015/wx-reactive/issues
- npm.io page: https://npm.io/package/wx-reactive

## Recent versions

- 1.2.0 (latest) — 2021-05-21
- 1.0.2 — 2021-05-20
- 1.0.1 — 2021-05-12
- 1.0.0 — 2021-05-12

## README

# wx-reactive

## 安装
`npm i wx-reactive`

## 使用
1、新建一个store.js
```
import { createStore } from "wx-reactive";


// 数据
export const store = createStore({
   token: "",
});

```
2、app.js 引入这个文件(路径根据实际来)
`import "./store"`

3、页面调用
```
import { pageReactive } from "wx-reactive";
// 引入自己创建的store(路径根据实际来)
import { store } from "../../store/index";

Page(reactive({
   data: {
      token: "",
   },
   onChangeName() {
      store.token = "tokenNewValue";
   },
}));
```

4、组件调用(同上)
`pageReactive`换成`componentReactive`

## 持久缓存示例
const token = wx.getStorageSync("token");

// 数据
export const store = createStore(
   {
      token,
   }, 
   (prop, value) => {
      if (prop === "token") {
         wx.setStorageSync("token", value);
      }
   }
);

```

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