first commit
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { signal } from "../src/index.ts";
|
||||
|
||||
test("signal skips equal writes and supports safe unsubscribe during notification", () => {
|
||||
const count = signal(0);
|
||||
const seen: number[] = [];
|
||||
let off = () => {};
|
||||
off = count.subscribe((value) => {
|
||||
seen.push(value);
|
||||
off();
|
||||
});
|
||||
count.set(0);
|
||||
count.update((value) => value + 1);
|
||||
count.set(2);
|
||||
expect(seen).toEqual([1]);
|
||||
expect(count.get()).toBe(2);
|
||||
});
|
||||
Reference in New Issue
Block a user