@dittolive/ditto 4.0.2-experimental.shutdown-support.1.darwin-arm64 → 4.0.2-experimental.shutdown-support.2.darwin-arm64

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/types/ditto.d.ts CHANGED
@@ -1380,6 +1380,11 @@ declare class Ditto {
1380
1380
  * @see {@link setOfflineOnlyLicenseToken | setOfflineOnlyLicenseToken()}
1381
1381
  */
1382
1382
  readonly isActivated: boolean;
1383
+ /**
1384
+ * `true` once {@link close | Ditto.close()} has been called, otherwise
1385
+ * `false`.
1386
+ */
1387
+ get isClosed(): boolean;
1383
1388
  /**
1384
1389
  * Returns `true` if sync is active, otherwise returns `false`. Use
1385
1390
  * {@link startSync | startSync()} to activate and {@link stopSync | stopSync()}
@@ -1539,18 +1544,50 @@ declare class Ditto {
1539
1544
  */
1540
1545
  disableSyncWithV3(): void;
1541
1546
  /**
1542
- * Shut down Ditto and release all resources. Must be called before recreating a Ditto instance
1543
- * that uses the same persistence directory.
1547
+ * Shut down Ditto and release all resources.
1548
+ *
1549
+ * Must be called before recreating a Ditto instance that uses the same
1550
+ * persistence directory.
1544
1551
  */
1545
1552
  close(): Promise<void>;
1546
1553
  /** @internal */
1547
1554
  keepAlive: KeepAlive;
1555
+ /**
1556
+ * The number of operations pending before the Ditto instance can be closed.
1557
+ *
1558
+ * For testing purposes only.
1559
+ * @internal */
1560
+ get numPendingOperations(): number;
1561
+ /**
1562
+ * Makes sure that the closure is executed only if the Ditto instance hasn't
1563
+ * been closed yet.
1564
+ *
1565
+ * @param closure the synchronous closure to execute.
1566
+ * @returns the result of the closure.
1567
+ * @throws if the Ditto instance was closed before calling this method.
1568
+ * @internal */
1569
+ deferClose<T>(closure: () => T): T;
1570
+ /**
1571
+ * Makes sure that the closure is executed to completion before the Ditto
1572
+ * instance is closed.
1573
+ *
1574
+ * Any calls to {@link close | `Ditto.close()`} will wait until the closure
1575
+ * has completed before closing the Ditto instance.
1576
+ *
1577
+ * @param closure the asynchronous closure to execute.
1578
+ * @returns the result of the closure.
1579
+ * @throws if the Ditto instance was closed before calling this method.
1580
+ * @internal */
1581
+ deferCloseAsync<T>(closure: () => Promise<T>): Promise<T>;
1548
1582
  private sync;
1549
- private isClosed;
1583
+ private _isClosed;
1584
+ private deferCloseAllowed;
1550
1585
  private isWebValid;
1551
1586
  private isX509Valid;
1552
1587
  private presenceManager;
1553
1588
  private transportConditionsManager;
1589
+ /** Set of pending operations that need to complete before the Ditto instance can be closed in a safe manner. */
1590
+ private pendingOperations;
1554
1591
  private authClientValidityChanged;
1555
1592
  private validateIdentity;
1556
1593
  private setSyncActive;