Finish pass on docs

This commit is contained in:
Jon Staab
2025-06-10 15:48:00 -07:00
parent 1a81768e8e
commit ee6fa8b956
19 changed files with 545 additions and 435 deletions
+2 -2
View File
@@ -26,7 +26,7 @@ export const makeRepositoryStore = ({throttle: t = 300}: {throttle?: number} = {
return () => repository.off("update", onUpdate)
},
{
set: (other: Repository) => repository.load(other.dump()),
onUpdate: (other: Repository) => repository.load(other.dump()),
},
)
@@ -53,6 +53,6 @@ export const makeTrackerStore = ({throttle: t = 300}: {throttle?: number} = {})
}
},
{
set: (other: Tracker) => tracker.load(other.relaysById),
onUpdate: (other: Tracker) => tracker.load(other.relaysById),
},
)
+3 -3
View File
@@ -6,7 +6,7 @@ type Start<T> = (set: Subscriber<T>) => Unsubscriber
export type CustomStoreOpts<T> = {
throttle?: number
set?: (x: T) => void
onUpdate?: (x: T) => void
}
export const custom = <T>(
@@ -30,13 +30,13 @@ export const custom = <T>(
get: () => value,
set: (newValue: T) => {
set(newValue)
opts.set?.(newValue)
opts.onUpdate?.(newValue)
},
update: (f: (value: T) => T) => {
const newValue = f(value)
set(newValue)
opts.set?.(newValue)
opts.onUpdate?.(newValue)
},
subscribe: (sub: Subscriber<T>) => {
if (opts.throttle) {