Skip to content

Commit

Permalink
Derived stores can't point to single values
Browse files Browse the repository at this point in the history
  • Loading branch information
acurrieclark committed Feb 7, 2024
1 parent 12719e9 commit 29f3370
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
2 changes: 1 addition & 1 deletion src/automerge-derived-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "svelte/store";
import type { AutomergeSvelteStoreInterface } from "./automerge-svelte-store.type";

export class AutomergeDerivedStore<T, U, V extends Stores = []>
export class AutomergeDerivedStore<T extends object, U, V extends Stores = []>
implements Readable<T>, AutomergeSvelteStoreInterface<T>
{
#rootStore: AutomergeSvelteStoreInterface<U>;
Expand Down
25 changes: 0 additions & 25 deletions tests/derived-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,31 +100,6 @@ describe("root store", () => {
});
});

test("single value derived stores can be changed", () => {
new Promise<void>((done) => {
let initialRun = true;

const singleValueStore = new AutomergeDerivedStore(
rootStore,
(doc) => doc.object?.hello,
);
singleValueStore.subscribe((hello) => {
if (initialRun) {
expect(hello).toEqual("world");
initialRun = false;
return;
}

expect(hello).toEqual("there world");
done();
});

singleValueStore.localChange(() => {
return "there world";
});
});
});

test("a derived store can switch based on a single other stores", () => {
const otherStore = writable("id-1");
const derivedStore = new AutomergeDerivedStore(
Expand Down

0 comments on commit 29f3370

Please sign in to comment.