@holonograph/client 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -93,6 +93,37 @@ status, an error code, and any details the lens returned.
93
93
 
94
94
  Everything is fully typed; the package ships its own type declarations.
95
95
 
96
+ ## Watching for changes
97
+
98
+ Pull-side alerting, transport-agnostic. Poll any windowed lens read on a cadence
99
+ and act only on the delta — a steady state is silent (the same "no all-quiet
100
+ pings" discipline the lens applies to its own output). You supply the fetch and
101
+ where the change goes; the client supplies the cadence and change-detection.
102
+
103
+ - **`watchByKey({ poll, intervalMs, keyOf, onChange })`** — poll a collection and
104
+ fire `onChange(diff)` only when items are `added` / `removed` / `changed`
105
+ (matched by `keyOf`). Returns a handle with `.stop()`. The first poll silently
106
+ seeds the baseline, so you only hear about change since the watch started (pass
107
+ `emitInitial: true` for a cold-start inventory).
108
+ - **`diffByKey(prev, next, keyOf)`** / **`hasChanges(diff)`** — the underlying
109
+ keyed diff, if you want change-detection without the loop.
110
+ - **`createPoller({ poll, intervalMs, onResult })`** — the bare cadence loop
111
+ (non-overlapping; errors isolated to `onError`, never kill the watcher).
112
+ - **`watchReconciliation(...)` / `watchEmission(...)`** — typed sugar over
113
+ `watchByKey` for the lens's reconciliation + emission reads.
114
+
115
+ ```ts
116
+ import { watchByKey } from '@holonograph/client';
117
+
118
+ const handle = watchByKey({
119
+ poll: (signal) => fetchReconciliation({ signal }), // your windowed read
120
+ intervalMs: 30_000,
121
+ keyOf: (row) => row.emissionStreamId,
122
+ onChange: (diff) => notifyOnCall(diff), // added / removed / changed only
123
+ });
124
+ // later: handle.stop();
125
+ ```
126
+
96
127
  ## Requirements
97
128
 
98
129
  This client does nothing on its own — it needs a **running Holonograph lens** to