# reactive-light

> A lightweight JavaScript reactivity system

Latest version **1.0.15** (published 2023-07-13) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.15 |
| Published | 2023-07-13 |
| First published | 2020-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Amir Goren |
| Maintainers | gorenamir |
| Keywords | reactivity, lightweight |

## Links

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

## Recent versions

- 1.0.15 (latest) — 2023-07-13
- 1.0.14 — 2023-07-12
- 1.0.13 — 2023-07-12
- 1.0.12 — 2023-07-12
- 1.0.11 — 2020-10-16
- 1.0.10 — 2020-10-09
- 1.0.9 — 2020-10-04
- 1.0.8 — 2020-10-03
- 1.0.7 — 2020-10-03
- 1.0.6 — 2020-09-30
- 1.0.5 — 2020-09-29
- 1.0.4 — 2020-09-27
- 1.0.3 — 2020-09-26
- 1.0.2 — 2020-09-26
- 1.0.1 — 2020-09-18
- … 1 more at https://npm.io/package/reactive-light/versions

## README

# reactive-light

reactive-light is a lightweight JavaScript reactivity system.

## Installation

```bash
npm install reactive-light
```

or

```bash
yarn add reactive-light
```

## Usage

```javascript
import { ref, computed, reactive, watch, watchEffect } from 'reactive-light'; // in browser
const { ref, computed, reactive, watch, watchEffect } = require('reactive-light'); // Node.js

const counter = ref(0);
const twoTimesCounter = computed(() => counter.value * 2);

watchEffect(() => {
    console.log('2 * counter =', twoTimesCounter.value);
});

setInterval(() => { counter.value++; }, 1000);


const state = reactive({
    msg: 'hello, world!'
});

watch(
    () => state.msg,
    (newMsg, oldMsg) => console.log('message changed!')
);

setTimeout(() => { state.msg = 'new message!'; }, 5000);

// Unsubscribe the watcher by calling the unsubscriber returned by watch()
const unwatch = watch(
    () => state.msg,
    (newMsg, oldMsg) => console.log('message changed!')
);

setTimeout(() => { unwatch(); }, 5000);
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

## License
[MIT](https://choosealicense.com/licenses/mit/)

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