# @akar/vue-hooks

> 提取了一些通用hooks

Latest version **0.1.5** (published 2022-09-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @akar/vue-hooks
pnpm add @akar/vue-hooks
yarn add @akar/vue-hooks
bun add @akar/vue-hooks
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2022-09-13 |
| First published | 2022-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ningrui |
| Maintainers | akar |
| Keywords | vue3, hooks, ts |

## Links

- npm: https://www.npmjs.com/package/@akar/vue-hooks
- Repository: https://github.com/kabudaaixuexi/npm-vue-hooks
- Homepage: https://github.com/kabudaaixuexi/npm-vue-hooks#readme
- Issues: https://github.com/kabudaaixuexi/npm-vue-hooks/issues
- npm.io page: https://npm.io/package/@akar/vue-hooks

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^3.2.33

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.1.5 (latest) — 2022-09-13
- 0.1.4 — 2022-09-13
- 0.1.3 — 2022-09-13
- 0.1.2 — 2022-05-20
- 0.1.1 — 2022-05-18
- 0.1.0 — 2022-05-18
- 0.0.9 — 2022-05-18
- 0.0.8 — 2022-05-18
- 0.0.7 — 2022-05-18
- 0.0.6 — 2022-05-14
- 0.0.5 — 2022-05-14
- 0.0.4 — 2022-05-14
- 0.0.3 — 2022-05-14
- 0.0.2 — 2022-05-14
- 0.0.1 — 2022-05-14

## README

### 基于Vue Componsition API，封装了一些通用hook

+ 介绍

使用vue-hooks库，提升开发效率，使代码更具有可读性

+ 安装

```
pnpm i @akar/vue-hooks 或 npm i @akar/vue-hooks
```

+ useState

```
<script lang="ts" setup>

import { useState } from '@akar/vue-hooks'

const [count, setCount] = useState(0);

setCount(1) // count = 1 

setCount(() => 100) // count = 100

setCount((count) => count.value + 1) // count = 101

</script>

```

+ useReducer

```
<script lang="ts" setup>

import { useReducer } from '@akar/vue-hooks'

const [count, countDispatch] = useReducer((count, { type, payload }) => {
  switch (type) {
    case "add":
      count.value = count.value + payload;
      break;
    case "reduce":
      count.value = count.value - payload;
      break;
  }
}, 100);

countDispatch({ type: 'add', payload: 3 }) // count = 103

countDispatch({ type: 'reduce', payload: 10 }) // count = 100

```


+ 建议

@akar/vue-hooks封装了一些基础的hook，会陆续提供更多的通用hook，建议每个vue开发者要能手写出来这些hooks，此插件在不断完善中

[vue响应式基础学习点击这里](https://v3.cn.vuejs.org/api/basic-reactivity.html#reactive "Vue3")

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