initial reactivity code

This commit is contained in:
laura 2025-11-08 13:35:04 -03:00
parent 884f773575
commit 1c361de610
Signed by: w
GPG key ID: BCD2117C99E69817
3 changed files with 607 additions and 0 deletions

View file

@ -5,6 +5,7 @@
import { createRouter } from "cobweb/routing";
import { Defer } from "cobweb/jsx-runtime";
import { computed, effect, signal } from "cobweb/signals.ts";
interface Todo {
id: string;
@ -61,3 +62,16 @@ app.get("/meow/:test?", async (ctx) => {
});
Deno.serve({ port: 8000 }, app.fetch);
const count = signal(1);
const doubleCount = computed(() => count() * 2);
effect(() => {
console.log(`Count is: ${count()}`);
});
console.log(doubleCount());
count(2);
console.log("meow", doubleCount());