# @endgame/calvin

> Changing Any Lifeless Value Into Notifications

Latest version **1.0.8-alpha.0** (published 2021-12-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @endgame/calvin
pnpm add @endgame/calvin
yarn add @endgame/calvin
bun add @endgame/calvin
```

## 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.8-alpha.0 |
| Published | 2021-12-21 |
| First published | 2020-04-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mental Breakdown |
| Maintainers | alphability |

## Links

- npm: https://www.npmjs.com/package/@endgame/calvin
- Repository: https://github.com/MBDW-Studio/endgame
- Homepage: https://github.com/MBDW-Studio/endgame#readme
- Issues: https://github.com/MBDW-Studio/endgame/issues
- npm.io page: https://npm.io/package/@endgame/calvin

## Recent versions

- 1.0.8-alpha.0 (latest) — 2021-12-21
- 1.0.7 — 2021-12-05
- 1.0.7-alpha.6 — 2021-09-11
- 1.0.7-alpha.5 — 2021-09-10
- 1.0.7-alpha.4 — 2021-09-09
- 1.0.7-alpha.3 — 2021-09-08
- 1.0.7-alpha.2 — 2021-08-28
- 1.0.7-alpha.1 — 2021-08-28
- 1.0.6-alpha.19 — 2021-08-28
- 1.0.6-alpha.18 — 2021-08-28
- 1.0.6-alpha.17 — 2021-08-27
- 1.0.6-alpha.16 — 2021-08-24
- 1.0.6-alpha.15 — 2021-08-24
- 1.0.6-alpha.14 — 2021-08-21
- 1.0.6-alpha.13 — 2021-08-20
- … 51 more at https://npm.io/package/@endgame/calvin/versions

## README

# CALVIN

> CALVIN: Changing Any Lifeless Value Into Notifications

## Installation

```sh
yarn add @endgame/calvin
# or
npm i -S @endgame/calvin
```

## Wait... WHY ?

Writing a lot of JS logic is very cool, stylish and SWAG... but putting too much logic in your files can make them bloated and hard to maintain.

**NOT ANYMORE!!!**

**NOW YOU CAN USE COMPUTED PROPERTIES AND WATCHERS... IN VANILLA JS 😱**

**P.S. TypeScript is fully supported**

## 🤔 Computed properties... watchers... WTF??? Are you even talking English man?

> Yeah dude... just read [thaaaaaaat](https://vuejs.org/v2/guide/computed.html) and then... only then... go cry to your mother!

## The example 😏

```js
import { Calvin } from '@endgame/calvin';

// Declare a new data reactor like this 🚀
const reactor = new Calvin({
  myReactiveData: 0,
});

// Declare computed properties this way
reactor.computed({
  myAwesomeComputed() {
    return `myReactiveData equals: ${this.myReactiveData}`;
  },
});

// Get notified any time a property is updated
reactor.watch({
  myReactiveData() {
    // This watcher will be called whenever you update myReactiveData

    // You can, for example, call a specific method on myReactiveData's update
    handleMyReactiveDataUpdate(this.myReactiveData);
  },
  myAwesomeComputed() {
    // This watcher will be called whenever myAwesomeComputed gets updated
    console.log(this.myAwesomeComputed);
  },
});

// Let's see what can be done with this cool reactor 🔥
// Try to run this loop to see what CALVIN does.
const letsSeeWhatCanBeDoneWithThisCoolReactor = () => {
  setTimeout(() => {
    // Add one every 1 seconds in order to test the reactor's features
    reactor.data.myReactiveData += 1;

    // Repeat it to test it... indefinitely 😍
    letsSeeWhatCanBeDoneWithThisCoolReactor();
  }, 1000);
};
```

## List of features

### Access data

```js
import { Calvin } from '@endgame/calvin';

const reactor = new Calvin({
  myReactiveData: 0,
});

reactor.computed({
  myComputed() {
    return `myReactiveData equals: ${this.myReactiveData}`;
  },
});

// Access the declared data and computed
console.log(reactor.data.myReactiveData);
console.log(reactor.data.myComputed);
```

### Watch

```js
import { Calvin } from '@endgame/calvin';

const reactor = new Calvin({
  myReactiveData: 0,
});

// Get notified any time myReactiveData is updated
reactor.watch({
  myReactiveData() {
    console.log(this.myReactiveData);
  },
});
```

### Unwatch

```js
import { Calvin } from '@endgame/calvin';

const reactor = new Calvin({
  myReactiveData: 0,
});

const watchersIds = reactor.watch({
  myReactiveData() {
    console.log(this.myReactiveData);
  },
});

// ⚡ Unwatch data to avoid memory leak
reactor.unwatch(watchersIds);
```

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