npm.io
1.1.0 • Published 6d ago

@xstd/signal

Licence
MIT
Version
1.1.0
Deps
2
Size
41 kB
Vulns
0
Weekly
27

npm (scoped) npm NPM npm type definitions

Shows a black logo in light color mode and a white one in dark color mode.

@xstd/signal

A Signal implementation based on alien-signals.

Installation

yarn add @xstd/signal
# or
npm install @xstd/signal --save

Example

import { signal, computed, batch } from '@xstd/signal';

const width = signal(10);
const height = signal(5);
const surface = computed(() => width() * height());

effect(() => {
  console.log(`surface: ${surface()}`);
});
// logs: surface: 50

batch(() => {
  // batch allows to update multiple signals at once
  width.set(20);
  height.set(10);
});
// logs: surface: 200

Documentation

https://xstd-js.github.io/signal

Keywords