1
0
Fork
You've already forked pkg-signals
0
Fast reactive signals https://jsr.io/@mary/signals
  • TypeScript 100%
2025年08月14日 09:41:01 +07:00
.vscode initial commit 2024年03月06日 19:57:46 +07:00
deno.json v0.2.0 2024年04月11日 14:30:30 +07:00
LICENSE initial commit 2024年03月06日 19:57:46 +07:00
mod.ts refactor: clean up more things 2025年06月28日 05:44:21 +07:00
README.md docs: update links in readme 2025年08月14日 09:41:01 +07:00
store.ts refactor: clean up more things 2025年06月28日 05:44:21 +07:00

signals

JSR | source code

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`