withWatch
function withWatch<S>(storage, subscribe): S & WatchableKvStorage;Defined in: src/storage/watch.ts:38
Wrap a storage so it implements WatchableKvStorage using subscribe as the change
source. The wrapper delegates every other member to storage and only adds watch; keys outside
the watched prefix are filtered out. A notification without a key is delivered as an update
of the prefix itself (enough to trigger a refresh).
The wrapper inherits from storage and carries every member of storage (own, inherited and
class methods, bound to storage) as an own enumerable property, so { ...withWatch(s, sub) }
keeps the methods (the copies’ Object.create-only wrapper lost them on spread).
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
S extends KvStorage |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
storage |
S |
subscribe |
WatchSubscribe |