# @vue-reactivity/watch

Latest version **0.2.0** (published 2022-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @vue-reactivity/watch
pnpm add @vue-reactivity/watch
yarn add @vue-reactivity/watch
bun add @vue-reactivity/watch
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2022-02-07 |
| First published | 2020-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 35.6 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 125 |
| Author | Anthony Fu <anthonyfu117@hotmail.com> |
| Maintainers | antfu |

## Links

- npm: https://www.npmjs.com/package/@vue-reactivity/watch
- Repository: https://github.com/antfu/vue-reactivity-watch.git
- npm.io page: https://npm.io/package/@vue-reactivity/watch

## Dependencies (1)

- [esbuild](https://npm.io/package/esbuild.md) ^0.14.19

## Recent versions

- 0.2.0 (latest) — 2022-02-07
- 0.1.6 — 2020-10-15
- 0.1.4 — 2020-10-13
- 0.1.2 — 2020-09-18
- 0.1.1 — 2020-09-17
- 0.1.0 — 2020-09-17

## README

<p align='center'>
<img src='https://github.com/vue-reactivity/art/blob/master/svg/package-watch.svg?raw=true' height='250'>
</p>

<p align='center'>
The (missing) <kbd>watch</kbd> for <a href="https://github.com/vuejs/vue-next/tree/master/packages/reactivity"><code>@vue/reactivity</code></a>. Works without Vue.</p>

<p align='center'>
  <a href="https://www.npmjs.com/package/@vue-reactivity/watch"><img src="https://img.shields.io/npm/v/@vue-reactivity/watch?color=43b883&label=" alt="npm"></a>
  <a href="https://bundlephobia.com/result?p=@vue-reactivity/watch"><img src="https://img.shields.io/bundlephobia/minzip/@vue-reactivity/watch?color=364a5e&label=" alt="npm bundle size"></a>
</p>

<p align='center'>
  <em>want to now how it works or write one on your own? Check out <a href='https://antfu.me/posts/watch-with-reactivity/'>this blog post</a></em>
</p>


## Install

<pre>
npm i @vue-reactivity/<b>watch</b>
</pre>

### Usage

> Note: since there is no Vue instance to be bond, `watch` will **NOT** be auto disposed. You need to always **explicitly** call the returning function to stop it. Or you can try [@vue-reactivity/scope](https://github.com/vue-reactivity/scope) which will auto collect the effects for you. 

Just like what you do in Vue.

```ts
import { ref, reactive, computed } from '@vue/reactivity'
import { watch, watchEffect } from '@vue-reactivity/watch'

const count = ref(1)

const stopWatch = watch(
  count,
  (newValue) => {
    console.log(`Count: ${newValue}`)
  }
)

count.value += 1
// Count: 2

stopWatch()
```

## License

MIT

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