@kokimoki/app 1.0.9 → 1.0.10

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.
@@ -10,4 +10,5 @@ export declare class KokimokiStore<T extends S.Generic<unknown>> {
10
10
  readonly defaultValue: T["defaultValue"];
11
11
  readonly docRoot: Y.Map<unknown>;
12
12
  constructor(roomName: string, schema: T, mode?: RoomSubscriptionMode);
13
+ subscribe(callback: (value: T["defaultValue"]) => void): () => void;
13
14
  }
@@ -45,4 +45,9 @@ export class KokimokiStore {
45
45
  // Set default value
46
46
  this.defaultValue = schema.defaultValue;
47
47
  }
48
+ subscribe(callback) {
49
+ const handler = () => callback(this.proxy);
50
+ this.doc.on("update", handler);
51
+ return () => this.doc.off("update", handler);
52
+ }
48
53
  }
@@ -214,6 +214,7 @@ declare class KokimokiStore<T extends KokimokiSchema.Generic<unknown>> {
214
214
  readonly defaultValue: T["defaultValue"];
215
215
  readonly docRoot: Y.Map<unknown>;
216
216
  constructor(roomName: string, schema: T, mode?: RoomSubscriptionMode);
217
+ subscribe(callback: (value: T["defaultValue"]) => void): () => void;
217
218
  }
218
219
 
219
220
  declare class KokimokiQueue<Req extends KokimokiSchema.Generic<unknown>> extends KokimokiStore<KokimokiSchema.Dict<KokimokiSchema.Struct<{
@@ -634,7 +634,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
634
634
  var eventsExports = events.exports;
635
635
  var EventEmitter$1 = /*@__PURE__*/getDefaultExportFromCjs(eventsExports);
636
636
 
637
- const KOKIMOKI_APP_VERSION = "1.0.9";
637
+ const KOKIMOKI_APP_VERSION = "1.0.10";
638
638
 
639
639
  /**
640
640
  * Utility module to work with key-value stores.
@@ -12370,6 +12370,11 @@ class KokimokiStore {
12370
12370
  // Set default value
12371
12371
  this.defaultValue = schema.defaultValue;
12372
12372
  }
12373
+ subscribe(callback) {
12374
+ const handler = () => callback(this.proxy);
12375
+ this.doc.on("update", handler);
12376
+ return () => this.doc.off("update", handler);
12377
+ }
12373
12378
  }
12374
12379
 
12375
12380
  class KokimokiQueue extends KokimokiStore {