A Signal implementation based on alien-signals.
yarn add @xstd/signal
# or
npm install @xstd/signal --save
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