@oddington/sdk 0.1.57 → 0.1.58

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
@@ -391,6 +391,13 @@ const proposed = await accounting.transact(tx => {
391
391
  await accounting.changes.publish(proposed, { summary: 'Invoice paid' });
392
392
  // Or discard an exact current owned selection before publication:
393
393
  // await accounting.changes.discard(proposed);
394
+
395
+ const unsubscribe = accounting.subscribe(({ records, changes }) => {
396
+ if (records) void reloadRecords(); // Ordinary reads now see the committed state.
397
+ if (changes) void reloadChanges();
398
+ });
399
+ // When this view leaves:
400
+ unsubscribe();
394
401
  ```
395
402
 
396
403
  Initialization confirms current access and the available artifact, reuses an
@@ -400,8 +407,9 @@ querying or exact reads. Stored Changes without publication information remain
400
407
  in `changes.list()` and never alter Records.
401
408
  `records.query`, `records.pages` and `records.all(query, { maxRecords })` use the existing query language and generated-schema inference.
402
409
  They read locally and expose the initialized version in `$meta.version`. The
403
- handle incorporates its own successful mutations; explicitly call `data.init`
404
- again to observe another client's later Changes or an operator-built snapshot. Single-ref `records.read(ref)`
410
+ handle incorporates its own successful mutations. Subscribe to observe another
411
+ client's later Changes or an operator-built snapshot; without listeners the
412
+ handle stays fixed except for its own successful operations. Single-ref `records.read(ref)`
405
413
  returns the complete structured Record or `null` from that same pinned state.
406
414
  Initialization never refreshes the hosted artifact. Sign-out, context replacement and expiry invalidate local reads.
407
415
  Snapshot initialization requires a hosted browser app; Node, routines and local
@@ -416,7 +424,24 @@ transact changes only shared unpublished work. Publish and discard require exact
416
424
  current owned Change IDs and versions. Publication uses the canonical writer and
417
425
  applies its confirmed effects to local Records and the same Changes before
418
426
  resolving, without waiting for hosted projection settlement. No operation
419
- refreshes the artifact or adds a client subscription or unpublished query overlay.
427
+ refreshes the artifact or adds an unpublished query overlay.
428
+
429
+ `subscribe(listener)` has no initial callback and returns a synchronous,
430
+ idempotent unsubscribe function. Listeners on one handle share a connection;
431
+ removing the last listener releases it. Each callback receives exactly
432
+ `{ records: boolean, changes: boolean }`, with at least one true, after atomic
433
+ local persistence. Callback-triggered ordinary reads see that committed state;
434
+ already-started reads remain pinned to their earlier installation. Unpublished
435
+ transact/discard affect Changes only; publication affects both namespaces. A
436
+ new artifact affects Records and also Changes when its relevant set changes.
437
+ Own successful operations notify once, including when their remote hint races
438
+ the response. Repeated hints and unchanged state do not notify.
439
+
440
+ The SDK reconciles on connection, reconnection and update hints, with bounded
441
+ reconnect backoff and no healthy-connection polling. Changes-only updates reuse
442
+ the unchanged artifact bytes. Subscription never builds or refreshes a snapshot.
443
+ Sign-out, context replacement and expiry stop live delivery and invalidate the
444
+ handle under the same local-operation rules.
420
445
 
421
446
  After a lost transact/discard response, `DataOperationError.effect` is
422
447
  `uncertain`, `retryable` is false, and that handle is invalid. Explicitly