Fast reactive signals
https://jsr.io/@mary/signals
- TypeScript 100%
| .vscode | initial commit | |
| deno.json | v0.2.0 | |
| LICENSE | initial commit | |
| mod.ts | refactor: clean up more things | |
| README.md | docs: update links in readme | |
| store.ts | refactor: clean up more things | |
signals
fast reactive signals.
const name = signal(`Mary`);
// run a side effect that gets rerun on state changes...
effect(() => {
console.log(`Hello, ${name.value}!`);
});
// logs `Hello, Mary!`
// combine multiple writes into a single update...
batch(() => {
name.value = `Elly`;
name.value = `Alice!`;
});
// logs `Hello, Alice!`
// run derivations that only gets updated as needed when not depended on...
const doubled = computed(() => {
console.log(`Computation ran!`);
return name.repeat(2);
});
doubled.value;
// logs `Computation ran!`
// -> `AliceAlice`
name.value = `Alina`;
// no logs as it's not being read under an effect yet!
doubled.value;
// logs `Computation ran!`
// -> `AlinaAlina`