Finish pass on docs
This commit is contained in:
@@ -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),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user