Skip to main content

リアクティブな を宣言するだけでなく、任意の ステートメント をリアクティブに実行することもできます。例えば、count の値が変化するたびにログを取ることができます。

$: console.log('the count is ' + count);

ブロックで簡単にステートメントをグループ化することができます。

$: {
	console.log('the count is ' + count);
	alert('I SAID THE COUNT IS ' + count);
}

if ブロックなどの前に $: を置くこともできます。

$: if (count >= 10) {
	alert('count is dangerously high!');
	count = 9;
}