Memoize some stores, improve room support

This commit is contained in:
Jon Staab
2025-11-03 13:20:53 -08:00
parent 3132b8c59a
commit 8426febcdf
6 changed files with 91 additions and 30 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
import {readable, derived, writable, Readable, Subscriber} from "svelte/store"
import {batch, indexBy, remove, assoc, now} from "@welshman/lib"
import {withGetter, ReadableWithGetter} from "./getter.js"
import {memoized} from "./memoize.js"
// Collection utility
@@ -126,7 +127,7 @@ export const collection = <T>({name, store, getKey, load}: CollectionOptions<T>)
// store will update when it arrives
loadItem(key, relays)
return derived(indexStore, $index => $index.get(key))
return memoized<T | undefined>(derived(indexStore, $index => $index.get(key)))
}
const onItem = (cb: Subscriber<T>) => {