@dittolive/ditto 2.0.7 → 2.1.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 +2 -2
- package/node/ditto.cjs.js +1 -1
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +2 -2
- package/types/ditto.d.ts +145 -58
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
package/types/ditto.d.ts
CHANGED
|
@@ -679,7 +679,7 @@ declare class MutableRGA extends RGA {
|
|
|
679
679
|
* @param value - The value to set at the specified index.
|
|
680
680
|
* @param index - The index at which to set the provided value.
|
|
681
681
|
*
|
|
682
|
-
* @deprecated
|
|
682
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
683
683
|
* instead.
|
|
684
684
|
*/
|
|
685
685
|
setAt(value: any, index: number): void;
|
|
@@ -693,7 +693,7 @@ declare class MutableRGA extends RGA {
|
|
|
693
693
|
*
|
|
694
694
|
* @param index - The index of the element to remove.
|
|
695
695
|
*
|
|
696
|
-
* @deprecated
|
|
696
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
697
697
|
* instead.
|
|
698
698
|
*/
|
|
699
699
|
removeAt(index: number): void;
|
|
@@ -707,7 +707,7 @@ declare class MutableRGA extends RGA {
|
|
|
707
707
|
*
|
|
708
708
|
* @param value - The value to push on to the RGA.
|
|
709
709
|
*
|
|
710
|
-
* @deprecated
|
|
710
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
711
711
|
* instead.
|
|
712
712
|
*/
|
|
713
713
|
push(value: any): void;
|
|
@@ -721,7 +721,7 @@ declare class MutableRGA extends RGA {
|
|
|
721
721
|
*
|
|
722
722
|
* @return The value popped off from the end of the RGA.
|
|
723
723
|
*
|
|
724
|
-
* @deprecated
|
|
724
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
725
725
|
* instead.
|
|
726
726
|
*/
|
|
727
727
|
pop(): any | null;
|
|
@@ -736,7 +736,7 @@ declare class MutableRGA extends RGA {
|
|
|
736
736
|
* @param value - The value to insert into the RGA.
|
|
737
737
|
* @param index - The index at which to insert the provided value.
|
|
738
738
|
*
|
|
739
|
-
* @deprecated
|
|
739
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
740
740
|
* instead.
|
|
741
741
|
*/
|
|
742
742
|
insertAt(value: any, index: number): void;
|
|
@@ -815,7 +815,7 @@ declare class DocumentPath {
|
|
|
815
815
|
* Returns the value at the previously specified key in the document as an
|
|
816
816
|
* {@link RGA} if possible, otherwise returns `null`.
|
|
817
817
|
*
|
|
818
|
-
* @deprecated
|
|
818
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
819
819
|
* instead.
|
|
820
820
|
*/
|
|
821
821
|
get rga(): RGA | null;
|
|
@@ -879,7 +879,7 @@ declare class MutableDocumentPath {
|
|
|
879
879
|
* Returns the value at the previously specified key in the document as a
|
|
880
880
|
* {@link MutableRGA} if possible, otherwise returns `null`.
|
|
881
881
|
*
|
|
882
|
-
* @deprecated
|
|
882
|
+
* @deprecated RGA usage should be replaced. Use arrays inside Registers
|
|
883
883
|
* instead.
|
|
884
884
|
*/
|
|
885
885
|
get rga(): MutableRGA | null;
|
|
@@ -1194,9 +1194,9 @@ declare class UpdateResultsMap {
|
|
|
1194
1194
|
|
|
1195
1195
|
/**
|
|
1196
1196
|
* The type that is returned when calling
|
|
1197
|
-
* {@link PendingCursorOperation.
|
|
1197
|
+
* {@link PendingCursorOperation.observeLocal | observeLocal()} on a
|
|
1198
1198
|
* {@link PendingCursorOperation} object. It handles the logic for calling the
|
|
1199
|
-
* event handler that is provided to `
|
|
1199
|
+
* event handler that is provided to `observeLocal()` calls.
|
|
1200
1200
|
*
|
|
1201
1201
|
* Ditto will prevent the process from exiting as long as there are
|
|
1202
1202
|
* active live queries (not relevant when running in the browser).
|
|
@@ -1377,7 +1377,7 @@ declare type QueryObservationHandler = (documents: Document[], event: LiveQueryE
|
|
|
1377
1377
|
* {@link Document | documents} as an immediate return value, or you can
|
|
1378
1378
|
* establish either a live query or a subscription, which both work over time.
|
|
1379
1379
|
*
|
|
1380
|
-
* A live query, established by calling {@link PendingCursorOperation.
|
|
1380
|
+
* A live query, established by calling {@link PendingCursorOperation.observeLocal | observeLocal()}, will notify
|
|
1381
1381
|
* you every time there's an update to a document that matches the query you
|
|
1382
1382
|
* provided in the preceding `find`-like call.
|
|
1383
1383
|
*
|
|
@@ -1386,12 +1386,6 @@ declare type QueryObservationHandler = (documents: Document[], event: LiveQueryE
|
|
|
1386
1386
|
* like to receive updates from them about documents that match the query you
|
|
1387
1387
|
* provided in the preceding `find`-like call.
|
|
1388
1388
|
*
|
|
1389
|
-
* Calling {@link PendingCursorOperation.observe | observe()} will generate both a subscription and a
|
|
1390
|
-
* live query at the same time.
|
|
1391
|
-
*
|
|
1392
|
-
* If you'd like to only observe local changes then you can call
|
|
1393
|
-
* {@link PendingCursorOperation.observeLocal | observeLocal()}.
|
|
1394
|
-
*
|
|
1395
1389
|
* Update and remove functionality is also exposed through this object.
|
|
1396
1390
|
*/
|
|
1397
1391
|
declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
@@ -1461,7 +1455,7 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1461
1455
|
*/
|
|
1462
1456
|
subscribe(): Subscription;
|
|
1463
1457
|
/**
|
|
1464
|
-
* Enables you to
|
|
1458
|
+
* Enables you to listen for changes that occur in a collection locally and
|
|
1465
1459
|
* remotely.
|
|
1466
1460
|
*
|
|
1467
1461
|
* The `handler` block will be called when local or remote changes are
|
|
@@ -1477,16 +1471,21 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1477
1471
|
*
|
|
1478
1472
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1479
1473
|
* as you want to keep receiving updates.
|
|
1474
|
+
*
|
|
1475
|
+
* @deprecated Use {@link PendingCursorOperation.observeLocal | observeLocal()}
|
|
1476
|
+
* and {@link PendingCursorOperation.subscribe | subscribe()} individually
|
|
1477
|
+
* instead. For more info, please consult the
|
|
1478
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1480
1479
|
*/
|
|
1481
1480
|
observe(handler: QueryObservationHandler): LiveQuery;
|
|
1482
1481
|
/**
|
|
1483
|
-
* Enables you to
|
|
1484
|
-
* remotely
|
|
1482
|
+
* Enables you to listen for changes that occur in a collection locally and
|
|
1483
|
+
* remotely and to signal when you are ready for the live query to deliver
|
|
1485
1484
|
* the next event.
|
|
1486
1485
|
*
|
|
1487
1486
|
* The `handler` block will be called when local or remote changes are
|
|
1488
1487
|
* made to documents that match the query generated by the chain of operations
|
|
1489
|
-
* that precedes the call to {@link PendingCursorOperation.
|
|
1488
|
+
* that precedes the call to {@link PendingCursorOperation.observeWithNextSignal | observeWithNextSignal()}. The returned
|
|
1490
1489
|
* {@link LiveQuery} object must be kept in scope for as long as you want the
|
|
1491
1490
|
* provided `handler` to be called when an update occurs.
|
|
1492
1491
|
*
|
|
@@ -1497,17 +1496,29 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1497
1496
|
*
|
|
1498
1497
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1499
1498
|
* as you want to keep receiving updates.
|
|
1499
|
+
*
|
|
1500
|
+
* @deprecated Use {@link PendingCursorOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
1501
|
+
* and {@link PendingCursorOperation.subscribe | subscribe()} individually
|
|
1502
|
+
* instead. For more info, please consult the
|
|
1503
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1500
1504
|
*/
|
|
1501
1505
|
observeWithNextSignal(handler: QueryObservationHandler): LiveQuery;
|
|
1502
1506
|
/**
|
|
1503
|
-
* Enables you to
|
|
1507
|
+
* Enables you to listen for changes that occur in a collection locally.
|
|
1508
|
+
*
|
|
1509
|
+
* The `handler` block will be called when local changes are
|
|
1510
|
+
* made to documents that match the query generated by the chain of operations
|
|
1511
|
+
* that precedes the call to {@link PendingCursorOperation.observeLocal | observeLocal()}.
|
|
1512
|
+
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
1513
|
+
* you want the provided `handler` to be called when an update occurs.
|
|
1504
1514
|
*
|
|
1505
1515
|
* This won't subscribe to receive changes made remotely by others and so it
|
|
1506
1516
|
* will only fire updates when a local change is made. If you want to receive
|
|
1507
|
-
* remotely performed updates as well
|
|
1508
|
-
*
|
|
1509
|
-
* {@link LiveQuery} object must be kept in scope
|
|
1510
|
-
* provided `eventHandler` to be called when an
|
|
1517
|
+
* remotely performed updates as well, you'll have to create a subscription
|
|
1518
|
+
* via {@link PendingCursorOperation.subscribe | subscribe()} with the
|
|
1519
|
+
* relevant query. The returned {@link LiveQuery} object must be kept in scope
|
|
1520
|
+
* for as long as you want the provided `eventHandler` to be called when an
|
|
1521
|
+
* update occurs.
|
|
1511
1522
|
*
|
|
1512
1523
|
* @param handler A closure that will be called every time there is a
|
|
1513
1524
|
* transaction committed to the store that involves modifications to documents
|
|
@@ -1518,14 +1529,22 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1518
1529
|
*/
|
|
1519
1530
|
observeLocal(handler: QueryObservationHandler): LiveQuery;
|
|
1520
1531
|
/**
|
|
1521
|
-
* Enables you to
|
|
1532
|
+
* Enables you to listen for changes that occur in a collection locally and
|
|
1522
1533
|
* to signal when you are ready for the live query to deliver the next event.
|
|
1523
1534
|
*
|
|
1524
|
-
* The `handler` block will be called when local
|
|
1535
|
+
* The `handler` block will be called when local changes are
|
|
1525
1536
|
* made to documents that match the query generated by the chain of operations
|
|
1526
|
-
* that precedes the call to {@link PendingCursorOperation.
|
|
1527
|
-
* {@link LiveQuery} object must be kept in scope for as long as
|
|
1528
|
-
* provided `handler` to be called when an update occurs.
|
|
1537
|
+
* that precedes the call to {@link PendingCursorOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}.
|
|
1538
|
+
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
1539
|
+
* you want the provided `handler` to be called when an update occurs.
|
|
1540
|
+
*
|
|
1541
|
+
* This won't subscribe to receive changes made remotely by others and so it
|
|
1542
|
+
* will only fire updates when a local change is made. If you want to receive
|
|
1543
|
+
* remotely performed updates as well, you'll have to create a subscription
|
|
1544
|
+
* via {@link PendingCursorOperation.subscribe | subscribe()} with the
|
|
1545
|
+
* relevant query. The returned {@link LiveQuery} object must be kept in scope
|
|
1546
|
+
* for as long as you want the provided `eventHandler` to be called when an
|
|
1547
|
+
* update occurs.
|
|
1529
1548
|
*
|
|
1530
1549
|
* @param handler A closure that will be called every time there is a
|
|
1531
1550
|
* transaction committed to the store that involves modifications to
|
|
@@ -1576,12 +1595,13 @@ declare class PendingCursorOperation implements PromiseLike<Document[]> {
|
|
|
1576
1595
|
/** @internal */
|
|
1577
1596
|
constructor(query: string, queryArgs: QueryArguments | null, collection: Collection);
|
|
1578
1597
|
/** @internal */
|
|
1598
|
+
_observe(handler: QueryObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery;
|
|
1599
|
+
/** @internal */
|
|
1579
1600
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
|
|
1580
1601
|
private queryArgsCBOR;
|
|
1581
1602
|
private currentLimit;
|
|
1582
1603
|
private currentOffset;
|
|
1583
1604
|
private orderBys;
|
|
1584
|
-
private _observe;
|
|
1585
1605
|
}
|
|
1586
1606
|
|
|
1587
1607
|
/**
|
|
@@ -1597,7 +1617,7 @@ declare type SingleObservationHandler = (document: Document | null, event: Singl
|
|
|
1597
1617
|
* return value, or you can establish either a live query or a subscription,
|
|
1598
1618
|
* which both work over time.
|
|
1599
1619
|
*
|
|
1600
|
-
* A live query, established by calling {@link PendingIDSpecificOperation.
|
|
1620
|
+
* A live query, established by calling {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, will notify
|
|
1601
1621
|
* you every time there's an update to the document with the ID you provided in
|
|
1602
1622
|
* the preceding {@link Collection.findByID | findByID()} call.
|
|
1603
1623
|
*
|
|
@@ -1606,12 +1626,6 @@ declare type SingleObservationHandler = (document: Document | null, event: Singl
|
|
|
1606
1626
|
* them about the document with the ID you provided in the preceding
|
|
1607
1627
|
* {@link Collection.findByID | findByID()} call.
|
|
1608
1628
|
*
|
|
1609
|
-
* Calling {@link PendingIDSpecificOperation.observe | observe()} will generate both a subscription and a
|
|
1610
|
-
* live query at the same time.
|
|
1611
|
-
*
|
|
1612
|
-
* If you'd like to only observe local changes then you can call
|
|
1613
|
-
* {@link PendingIDSpecificOperation.observeLocal | observeLocal()}.
|
|
1614
|
-
*
|
|
1615
1629
|
* Update and remove functionality is also exposed through this object.
|
|
1616
1630
|
*/
|
|
1617
1631
|
declare class PendingIDSpecificOperation implements PromiseLike<Document | undefined> {
|
|
@@ -1652,6 +1666,11 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1652
1666
|
*
|
|
1653
1667
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1654
1668
|
* as you want to keep receiving updates.
|
|
1669
|
+
*
|
|
1670
|
+
* @deprecated Use {@link PendingIDSpecificOperation.observeLocal | observeLocal()}
|
|
1671
|
+
* and {@link PendingIDSpecificOperation.subscribe | subscribe()} individually
|
|
1672
|
+
* instead. For more info, please consult the
|
|
1673
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1655
1674
|
*/
|
|
1656
1675
|
observe(handler: SingleObservationHandler): LiveQuery;
|
|
1657
1676
|
/**
|
|
@@ -1661,7 +1680,7 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1661
1680
|
*
|
|
1662
1681
|
* The `handler` closure will be called when local or remote changes are
|
|
1663
1682
|
* made to the document referenced by the {@link Collection.findByID | findByID()} call
|
|
1664
|
-
* that precedes the call to {@link PendingIDSpecificOperation.
|
|
1683
|
+
* that precedes the call to {@link PendingIDSpecificOperation.observeWithNextSignal | observeWithNextSignal()}.
|
|
1665
1684
|
*
|
|
1666
1685
|
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
1667
1686
|
* you want the provided `handler` to be called when an update occurs.
|
|
@@ -1669,10 +1688,15 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1669
1688
|
* @param handler A closure that will be called every time there is a
|
|
1670
1689
|
* transaction committed to the store that involves a modification to the
|
|
1671
1690
|
* document with the relevant ID in the collection that
|
|
1672
|
-
* {@link PendingIDSpecificOperation.
|
|
1691
|
+
* {@link PendingIDSpecificOperation.observeWithNextSignal | observeWithNextSignal()} was called on.
|
|
1673
1692
|
*
|
|
1674
1693
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
1675
1694
|
* as you want to keep receiving updates.
|
|
1695
|
+
*
|
|
1696
|
+
* @deprecated Use {@link PendingIDSpecificOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
1697
|
+
* and {@link PendingIDSpecificOperation.subscribe | subscribe()} individually
|
|
1698
|
+
* instead. For more info, please consult the
|
|
1699
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
1676
1700
|
*/
|
|
1677
1701
|
observeWithNextSignal(handler: SingleObservationHandler): LiveQuery;
|
|
1678
1702
|
/**
|
|
@@ -1681,9 +1705,9 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1681
1705
|
*
|
|
1682
1706
|
* This won't subscribe to receive changes made remotely by others and so it
|
|
1683
1707
|
* will only fire updates when a local change is made. If you want to receive
|
|
1684
|
-
* remotely performed updates as well
|
|
1685
|
-
*
|
|
1686
|
-
*
|
|
1708
|
+
* remotely performed updates as well, you'll have to create a subscription
|
|
1709
|
+
* via {@link PendingIDSpecificOperation.subscribe | subscribe()} for the same
|
|
1710
|
+
* document ID.
|
|
1687
1711
|
*
|
|
1688
1712
|
* The returned {@link LiveQuery} object must be kept in scope for as long
|
|
1689
1713
|
* as you want the provided `handler` to be called when an update
|
|
@@ -1700,14 +1724,14 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1700
1724
|
observeLocal(handler: SingleObservationHandler): LiveQuery;
|
|
1701
1725
|
/**
|
|
1702
1726
|
* Enables you to listen for changes that occur in relation to a document
|
|
1703
|
-
* locally
|
|
1727
|
+
* locally and to signal when you are ready for the live query to deliver
|
|
1704
1728
|
* the next event.
|
|
1705
1729
|
*
|
|
1706
1730
|
* This won't subscribe to receive changes made remotely by others and so it
|
|
1707
1731
|
* will only fire updates when a local change is made. If you want to receive
|
|
1708
|
-
* remotely performed updates as well
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1732
|
+
* remotely performed updates as well, you'll have to create a subscription
|
|
1733
|
+
* via {@link PendingIDSpecificOperation.subscribe | subscribe()} for the same
|
|
1734
|
+
* document ID.
|
|
1711
1735
|
*
|
|
1712
1736
|
* The returned {@link LiveQuery} object must be kept in scope for as long
|
|
1713
1737
|
* as you want the provided `handler` to be called when an update
|
|
@@ -1759,10 +1783,11 @@ declare class PendingIDSpecificOperation implements PromiseLike<Document | undef
|
|
|
1759
1783
|
/** @internal */
|
|
1760
1784
|
constructor(documentID: DocumentID, collection: Collection);
|
|
1761
1785
|
/** @internal */
|
|
1786
|
+
_observe(handler: SingleObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery;
|
|
1787
|
+
/** @internal */
|
|
1762
1788
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
|
|
1763
1789
|
private documentIDCBOR;
|
|
1764
1790
|
private get query();
|
|
1765
|
-
private _observe;
|
|
1766
1791
|
}
|
|
1767
1792
|
|
|
1768
1793
|
declare type UpsertOptions = {
|
|
@@ -1785,9 +1810,9 @@ declare class Collection {
|
|
|
1785
1810
|
* Generates a {@link PendingCursorOperation} using the provided query.
|
|
1786
1811
|
*
|
|
1787
1812
|
* The returned object can be used to find and return the documents or you can
|
|
1788
|
-
* chain a call to `
|
|
1789
|
-
* the list of matching documents over time. It can also be used to
|
|
1790
|
-
* remove or evict the matching documents.
|
|
1813
|
+
* chain a call to `observeLocal()` or `subscribe()` if you want to get updates
|
|
1814
|
+
* about the list of matching documents over time. It can also be used to
|
|
1815
|
+
* update, remove or evict the matching documents.
|
|
1791
1816
|
*
|
|
1792
1817
|
* You can incorporate dynamic data into the query string with placeholders
|
|
1793
1818
|
* in the form of `$args.my_arg_name`, along with providing an accompanying
|
|
@@ -1811,7 +1836,7 @@ declare class Collection {
|
|
|
1811
1836
|
* ID.
|
|
1812
1837
|
*
|
|
1813
1838
|
* The returned object can be used to find and return the document or you can
|
|
1814
|
-
* chain a call to {@link PendingIDSpecificOperation.
|
|
1839
|
+
* chain a call to {@link PendingIDSpecificOperation.observeLocal | observeLocal()}, or {@link PendingIDSpecificOperation.subscribe | subscribe()}
|
|
1815
1840
|
* if you want to get updates about the document over time. It can also be
|
|
1816
1841
|
* used to update, remove or evict the document.
|
|
1817
1842
|
*
|
|
@@ -1955,7 +1980,7 @@ declare class CollectionsEvent {
|
|
|
1955
1980
|
* The closure that is called whenever the collections covered by a live query
|
|
1956
1981
|
* change.
|
|
1957
1982
|
*/
|
|
1958
|
-
declare type CollectionsObservationHandler = (event: CollectionsEvent) => void | Promise<void>;
|
|
1983
|
+
declare type CollectionsObservationHandler = (event: CollectionsEvent, signalNext?: () => void) => void | Promise<void>;
|
|
1959
1984
|
/**
|
|
1960
1985
|
* These objects are returned when calling {@link Store.collections | collections()}
|
|
1961
1986
|
* on {@link Store}.
|
|
@@ -1965,16 +1990,13 @@ declare type CollectionsObservationHandler = (event: CollectionsEvent) => void |
|
|
|
1965
1990
|
* {@link Collection}s as an immediate return value, or you can establish either
|
|
1966
1991
|
* a live query or a subscription, which both work over time.
|
|
1967
1992
|
*
|
|
1968
|
-
* A live query, established by calling {@link PendingCollectionsOperation.
|
|
1993
|
+
* A live query, established by calling {@link PendingCollectionsOperation.observeLocal | observeLocal()}, will notify
|
|
1969
1994
|
* you every time there's a change in the collections that the device knows
|
|
1970
1995
|
* about.
|
|
1971
1996
|
*
|
|
1972
1997
|
* A subscription, established by calling {@link subscribe | subscribe()}, will
|
|
1973
1998
|
* act as a signal to other peers that the device connects to that you would
|
|
1974
1999
|
* like to receive updates from them about the collections that they know about.
|
|
1975
|
-
*
|
|
1976
|
-
* Calling {@link PendingCollectionsOperation.observe | observe()} will generate both a subscription and a
|
|
1977
|
-
* live query at the same time.
|
|
1978
2000
|
*/
|
|
1979
2001
|
declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
|
|
1980
2002
|
/**
|
|
@@ -2039,8 +2061,72 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
|
|
|
2039
2061
|
*
|
|
2040
2062
|
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2041
2063
|
* as you want to keep receiving updates.
|
|
2064
|
+
*
|
|
2065
|
+
* @deprecated Use {@link PendingCollectionsOperation.observeLocal | observeLocal()}
|
|
2066
|
+
* and {@link PendingCollectionsOperation.subscribe | subscribe()}
|
|
2067
|
+
* individually instead. For more info, please consult the
|
|
2068
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
2042
2069
|
*/
|
|
2043
2070
|
observe(handler: CollectionsObservationHandler): LiveQuery;
|
|
2071
|
+
/**
|
|
2072
|
+
* Enables you to listen for changes that occur in relation to the collections
|
|
2073
|
+
* that are known about. A block gets called when an update is received either
|
|
2074
|
+
* locally or remotely. You can signal when you are ready for the next event
|
|
2075
|
+
* to be delivered.
|
|
2076
|
+
*
|
|
2077
|
+
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
2078
|
+
* you want the provided `handler` to be called when an update occurs.
|
|
2079
|
+
*
|
|
2080
|
+
* @param handler A closure that will be called every time there is an update
|
|
2081
|
+
* about the list of known about collections.
|
|
2082
|
+
*
|
|
2083
|
+
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2084
|
+
* as you want to keep receiving updates.
|
|
2085
|
+
*
|
|
2086
|
+
* @deprecated Use {@link PendingCollectionsOperation.observeLocalWithNextSignal | observeLocalWithNextSignal()}
|
|
2087
|
+
* and {@link PendingCollectionsOperation.subscribe | subscribe()}
|
|
2088
|
+
* individually instead. For more info, please consult the
|
|
2089
|
+
* {@link https://docs.ditto.live/javascript/common/concepts/syncing-data | corresponding Ditto docs}.
|
|
2090
|
+
*/
|
|
2091
|
+
observeWithNextSignal(handler: CollectionsObservationHandler): LiveQuery;
|
|
2092
|
+
/**
|
|
2093
|
+
* Enables you to listen for changes that occur in relation to the collections
|
|
2094
|
+
* that are known about locally.
|
|
2095
|
+
*
|
|
2096
|
+
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
2097
|
+
* you want the provided `handler` to be called when an update occurs.
|
|
2098
|
+
*
|
|
2099
|
+
* This won't subscribe to receive updates from other devices and so it will
|
|
2100
|
+
* only fire when a local change to the known about collections occurs. If
|
|
2101
|
+
* you want to receive remote updates as well, then create a subscription via
|
|
2102
|
+
* {@link PendingCollectionsOperation.subscribe | subscribe()}.
|
|
2103
|
+
*
|
|
2104
|
+
* @param handler A closure that will be called every time there is an update
|
|
2105
|
+
* about the list of known about collections.
|
|
2106
|
+
*
|
|
2107
|
+
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2108
|
+
* as you want to keep receiving updates.
|
|
2109
|
+
*/
|
|
2110
|
+
observeLocal(handler: CollectionsObservationHandler): LiveQuery;
|
|
2111
|
+
/**
|
|
2112
|
+
* Enables you to listen for changes that occur in relation to the collections
|
|
2113
|
+
* that are known about locally.
|
|
2114
|
+
*
|
|
2115
|
+
* The returned {@link LiveQuery} object must be kept in scope for as long as
|
|
2116
|
+
* you want the provided `handler` to be called when an update occurs.
|
|
2117
|
+
*
|
|
2118
|
+
* This won't subscribe to receive updates from other devices and so it will
|
|
2119
|
+
* only fire when a local change to the known about collections occurs. If
|
|
2120
|
+
* you want to receive remote updates as well, then create a subscription via
|
|
2121
|
+
* {@link PendingCollectionsOperation.subscribe | subscribe()}.
|
|
2122
|
+
*
|
|
2123
|
+
* @param handler A closure that will be called every time there is an update
|
|
2124
|
+
* about the list of known about collections.
|
|
2125
|
+
*
|
|
2126
|
+
* @return A {@link LiveQuery} object that must be kept in scope for as long
|
|
2127
|
+
* as you want to keep receiving updates.
|
|
2128
|
+
*/
|
|
2129
|
+
observeLocalWithNextSignal(handler: CollectionsObservationHandler): LiveQuery;
|
|
2044
2130
|
/**
|
|
2045
2131
|
* Return the list of collections requested based on the preceding function
|
|
2046
2132
|
* chaining.
|
|
@@ -2055,7 +2141,8 @@ declare class PendingCollectionsOperation implements PromiseLike<Collection[]> {
|
|
|
2055
2141
|
constructor(store: Store);
|
|
2056
2142
|
/** @internal */
|
|
2057
2143
|
then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2>;
|
|
2058
|
-
/** @
|
|
2144
|
+
/** @internal */
|
|
2145
|
+
_observe(handler: CollectionsObservationHandler, createSubscription: boolean, waitForNextSignal: boolean): LiveQuery;
|
|
2059
2146
|
private readonly pendingCursorOperation;
|
|
2060
2147
|
}
|
|
2061
2148
|
|