# @stacksjs/signals

> The Stacks signals integration, based on Maverick.

Latest version **0.58.73** (published 2024-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @stacksjs/signals
pnpm add @stacksjs/signals
yarn add @stacksjs/signals
bun add @stacksjs/signals
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.58.73 |
| Published | 2024-02-21 |
| First published | 2023-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 4 |
| Unpacked size | 4.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Chris Breuer |
| Maintainers | chrisbreuer |
| Keywords | signals, reactivity, maverick, stacks |

## Links

- npm: https://www.npmjs.com/package/@stacksjs/signals
- Repository: https://github.com/stacksjs/stacks
- Homepage: https://github.com/stacksjs/stacks/tree/main/storage/framework/core/signals#readme
- Issues: https://github.com/stacksjs/stacks/issues
- Funding: https://github.com/sponsors/chrisbbreuer
- npm.io page: https://npm.io/package/@stacksjs/signals

## Dependencies (4)

- [@stacksjs/cli](https://npm.io/package/@stacksjs/cli.md) latest
- [@stacksjs/types](https://npm.io/package/@stacksjs/types.md) latest
- [@stacksjs/config](https://npm.io/package/@stacksjs/config.md) latest
- [@maverick-js/signals](https://npm.io/package/@maverick-js/signals.md) ^5.11.4

## Recent versions

- 0.58.73 (latest) — 2024-02-21
- 0.58.72 — 2024-02-17
- 0.58.71 — 2024-02-14
- 0.58.70 — 2024-02-14
- 0.58.69 — 2024-02-14
- 0.58.68 — 2024-02-14
- 0.58.67 — 2024-02-14
- 0.58.66 — 2024-02-14
- 0.58.65 — 2024-02-13
- 0.58.64 — 2024-02-13
- 0.58.63 — 2024-02-13
- 0.58.62 — 2024-02-13
- 0.58.61 — 2024-02-12
- 0.58.60 — 2024-02-12
- 0.58.59 — 2024-02-11
- … 49 more at https://npm.io/package/@stacksjs/signals/versions

## README

# Stacks Signals

Stacks proxies [https://github.com/maverick-js/signals](Maverick.js's) signals.

## ☘️ Features

- 🪶 Light (~1kB minzipped)
- 💽 Works in both browsers and Node.js
- 🌎 All types are observable (i.e., string, array, object, etc.)
- 🕵️‍♀️ Only updates when value has changed
- ⏱️ Batched updates via microtask scheduler
- 😴 Lazy by default - efficiently re-computes only what's needed
- 🔬 Computations via computed
- 📞 Effect subscriptions via effect
- 🐛 Debugging identifiers
- 💪 Strongly typed

## 🤖 Usage

```bash
bun install -d @stacksjs/signals
```

You may now use it in your project:

```ts
import { computedSignal, effect, root, signal, tick } from '@stacksjs/signals'

root((dispose) => {
  // Create - all types supported (string, array, object, etc.)
  const $m = signal(1)
  const $x = signal(1)
  const $b = signal(0)

  // Compute - only re-computed when `$m`, `$x`, or `$b` changes.
  const $y = computedSignal(() => $m() * $x() + $b())

  // Effect - this will run whenever `$y` is updated.
  const stop = effect(() => {
    console.log($y())

    // Called each time `effect` ends and when finally disposed.
    return () => {}
  })

  $m.set(10) // logs `10` inside effect

  // Flush queue synchronously so effect is run.
  // Otherwise, effects will be batched and run on the microtask queue.
  tick()

  $b.set(prev => prev + 5) // logs `15` inside effect

  tick()

  // Nothing has changed - no re-compute.
  $y()

  // Stop running effect.
  stop()

  // ...

  // Dispose of all signals inside `root`.
  dispose()
})
```

## 🧪 Testing

```bash
bun test
```

## 📈 Changelog

Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.

## 🚜 Contributing

Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.

## 🏝 Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)

For casual chit-chat with others using this package:

[Join the Stacks Discord Server](https://discord.gg/stacksjs)

## 🙏🏼 Credits

Many thanks to the following core technologies & people who have contributed to this package:

- [Rahim Alwer](https://github.com/maverick-js/signals)
- [Chris Breuer](https://github.com/chrisbbreuer)
- [All Contributors](../../contributors)

## 📄 License

The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.

Made with 💙

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