@livequery/core 2.0.76 → 2.0.78
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 +97 -160
- package/dist/LivequeryCollection.d.ts +2 -0
- package/dist/LivequeryCollection.d.ts.map +1 -1
- package/dist/LivequeryCore.d.ts.map +1 -1
- package/dist/index.js +242 -13
- package/dist/index.js.map +13 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1618,6 +1618,240 @@ function of() {
|
|
|
1618
1618
|
function concatMap(project, resultSelector) {
|
|
1619
1619
|
return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
|
|
1620
1620
|
}
|
|
1621
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/Action.js
|
|
1622
|
+
var Action = function(_super) {
|
|
1623
|
+
__extends(Action2, _super);
|
|
1624
|
+
function Action2(scheduler, work) {
|
|
1625
|
+
return _super.call(this) || this;
|
|
1626
|
+
}
|
|
1627
|
+
Action2.prototype.schedule = function(state, delay) {
|
|
1628
|
+
if (delay === undefined) {
|
|
1629
|
+
delay = 0;
|
|
1630
|
+
}
|
|
1631
|
+
return this;
|
|
1632
|
+
};
|
|
1633
|
+
return Action2;
|
|
1634
|
+
}(Subscription);
|
|
1635
|
+
|
|
1636
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
|
|
1637
|
+
var intervalProvider = {
|
|
1638
|
+
setInterval: function(handler, timeout) {
|
|
1639
|
+
var args = [];
|
|
1640
|
+
for (var _i = 2;_i < arguments.length; _i++) {
|
|
1641
|
+
args[_i - 2] = arguments[_i];
|
|
1642
|
+
}
|
|
1643
|
+
var delegate = intervalProvider.delegate;
|
|
1644
|
+
if (delegate === null || delegate === undefined ? undefined : delegate.setInterval) {
|
|
1645
|
+
return delegate.setInterval.apply(delegate, __spreadArray([handler, timeout], __read(args)));
|
|
1646
|
+
}
|
|
1647
|
+
return setInterval.apply(undefined, __spreadArray([handler, timeout], __read(args)));
|
|
1648
|
+
},
|
|
1649
|
+
clearInterval: function(handle) {
|
|
1650
|
+
var delegate = intervalProvider.delegate;
|
|
1651
|
+
return ((delegate === null || delegate === undefined ? undefined : delegate.clearInterval) || clearInterval)(handle);
|
|
1652
|
+
},
|
|
1653
|
+
delegate: undefined
|
|
1654
|
+
};
|
|
1655
|
+
|
|
1656
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js
|
|
1657
|
+
var AsyncAction = function(_super) {
|
|
1658
|
+
__extends(AsyncAction2, _super);
|
|
1659
|
+
function AsyncAction2(scheduler, work) {
|
|
1660
|
+
var _this = _super.call(this, scheduler, work) || this;
|
|
1661
|
+
_this.scheduler = scheduler;
|
|
1662
|
+
_this.work = work;
|
|
1663
|
+
_this.pending = false;
|
|
1664
|
+
return _this;
|
|
1665
|
+
}
|
|
1666
|
+
AsyncAction2.prototype.schedule = function(state, delay) {
|
|
1667
|
+
var _a;
|
|
1668
|
+
if (delay === undefined) {
|
|
1669
|
+
delay = 0;
|
|
1670
|
+
}
|
|
1671
|
+
if (this.closed) {
|
|
1672
|
+
return this;
|
|
1673
|
+
}
|
|
1674
|
+
this.state = state;
|
|
1675
|
+
var id = this.id;
|
|
1676
|
+
var scheduler = this.scheduler;
|
|
1677
|
+
if (id != null) {
|
|
1678
|
+
this.id = this.recycleAsyncId(scheduler, id, delay);
|
|
1679
|
+
}
|
|
1680
|
+
this.pending = true;
|
|
1681
|
+
this.delay = delay;
|
|
1682
|
+
this.id = (_a = this.id) !== null && _a !== undefined ? _a : this.requestAsyncId(scheduler, this.id, delay);
|
|
1683
|
+
return this;
|
|
1684
|
+
};
|
|
1685
|
+
AsyncAction2.prototype.requestAsyncId = function(scheduler, _id, delay) {
|
|
1686
|
+
if (delay === undefined) {
|
|
1687
|
+
delay = 0;
|
|
1688
|
+
}
|
|
1689
|
+
return intervalProvider.setInterval(scheduler.flush.bind(scheduler, this), delay);
|
|
1690
|
+
};
|
|
1691
|
+
AsyncAction2.prototype.recycleAsyncId = function(_scheduler, id, delay) {
|
|
1692
|
+
if (delay === undefined) {
|
|
1693
|
+
delay = 0;
|
|
1694
|
+
}
|
|
1695
|
+
if (delay != null && this.delay === delay && this.pending === false) {
|
|
1696
|
+
return id;
|
|
1697
|
+
}
|
|
1698
|
+
if (id != null) {
|
|
1699
|
+
intervalProvider.clearInterval(id);
|
|
1700
|
+
}
|
|
1701
|
+
return;
|
|
1702
|
+
};
|
|
1703
|
+
AsyncAction2.prototype.execute = function(state, delay) {
|
|
1704
|
+
if (this.closed) {
|
|
1705
|
+
return new Error("executing a cancelled action");
|
|
1706
|
+
}
|
|
1707
|
+
this.pending = false;
|
|
1708
|
+
var error = this._execute(state, delay);
|
|
1709
|
+
if (error) {
|
|
1710
|
+
return error;
|
|
1711
|
+
} else if (this.pending === false && this.id != null) {
|
|
1712
|
+
this.id = this.recycleAsyncId(this.scheduler, this.id, null);
|
|
1713
|
+
}
|
|
1714
|
+
};
|
|
1715
|
+
AsyncAction2.prototype._execute = function(state, _delay) {
|
|
1716
|
+
var errored = false;
|
|
1717
|
+
var errorValue;
|
|
1718
|
+
try {
|
|
1719
|
+
this.work(state);
|
|
1720
|
+
} catch (e) {
|
|
1721
|
+
errored = true;
|
|
1722
|
+
errorValue = e ? e : new Error("Scheduled action threw falsy error");
|
|
1723
|
+
}
|
|
1724
|
+
if (errored) {
|
|
1725
|
+
this.unsubscribe();
|
|
1726
|
+
return errorValue;
|
|
1727
|
+
}
|
|
1728
|
+
};
|
|
1729
|
+
AsyncAction2.prototype.unsubscribe = function() {
|
|
1730
|
+
if (!this.closed) {
|
|
1731
|
+
var _a = this, id = _a.id, scheduler = _a.scheduler;
|
|
1732
|
+
var actions = scheduler.actions;
|
|
1733
|
+
this.work = this.state = this.scheduler = null;
|
|
1734
|
+
this.pending = false;
|
|
1735
|
+
arrRemove(actions, this);
|
|
1736
|
+
if (id != null) {
|
|
1737
|
+
this.id = this.recycleAsyncId(scheduler, id, null);
|
|
1738
|
+
}
|
|
1739
|
+
this.delay = null;
|
|
1740
|
+
_super.prototype.unsubscribe.call(this);
|
|
1741
|
+
}
|
|
1742
|
+
};
|
|
1743
|
+
return AsyncAction2;
|
|
1744
|
+
}(Action);
|
|
1745
|
+
|
|
1746
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js
|
|
1747
|
+
var dateTimestampProvider = {
|
|
1748
|
+
now: function() {
|
|
1749
|
+
return (dateTimestampProvider.delegate || Date).now();
|
|
1750
|
+
},
|
|
1751
|
+
delegate: undefined
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
// node_modules/rxjs/dist/esm5/internal/Scheduler.js
|
|
1755
|
+
var Scheduler = function() {
|
|
1756
|
+
function Scheduler2(schedulerActionCtor, now) {
|
|
1757
|
+
if (now === undefined) {
|
|
1758
|
+
now = Scheduler2.now;
|
|
1759
|
+
}
|
|
1760
|
+
this.schedulerActionCtor = schedulerActionCtor;
|
|
1761
|
+
this.now = now;
|
|
1762
|
+
}
|
|
1763
|
+
Scheduler2.prototype.schedule = function(work, delay, state) {
|
|
1764
|
+
if (delay === undefined) {
|
|
1765
|
+
delay = 0;
|
|
1766
|
+
}
|
|
1767
|
+
return new this.schedulerActionCtor(this, work).schedule(state, delay);
|
|
1768
|
+
};
|
|
1769
|
+
Scheduler2.now = dateTimestampProvider.now;
|
|
1770
|
+
return Scheduler2;
|
|
1771
|
+
}();
|
|
1772
|
+
|
|
1773
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js
|
|
1774
|
+
var AsyncScheduler = function(_super) {
|
|
1775
|
+
__extends(AsyncScheduler2, _super);
|
|
1776
|
+
function AsyncScheduler2(SchedulerAction, now) {
|
|
1777
|
+
if (now === undefined) {
|
|
1778
|
+
now = Scheduler.now;
|
|
1779
|
+
}
|
|
1780
|
+
var _this = _super.call(this, SchedulerAction, now) || this;
|
|
1781
|
+
_this.actions = [];
|
|
1782
|
+
_this._active = false;
|
|
1783
|
+
return _this;
|
|
1784
|
+
}
|
|
1785
|
+
AsyncScheduler2.prototype.flush = function(action) {
|
|
1786
|
+
var actions = this.actions;
|
|
1787
|
+
if (this._active) {
|
|
1788
|
+
actions.push(action);
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
var error;
|
|
1792
|
+
this._active = true;
|
|
1793
|
+
do {
|
|
1794
|
+
if (error = action.execute(action.state, action.delay)) {
|
|
1795
|
+
break;
|
|
1796
|
+
}
|
|
1797
|
+
} while (action = actions.shift());
|
|
1798
|
+
this._active = false;
|
|
1799
|
+
if (error) {
|
|
1800
|
+
while (action = actions.shift()) {
|
|
1801
|
+
action.unsubscribe();
|
|
1802
|
+
}
|
|
1803
|
+
throw error;
|
|
1804
|
+
}
|
|
1805
|
+
};
|
|
1806
|
+
return AsyncScheduler2;
|
|
1807
|
+
}(Scheduler);
|
|
1808
|
+
|
|
1809
|
+
// node_modules/rxjs/dist/esm5/internal/scheduler/async.js
|
|
1810
|
+
var asyncScheduler = new AsyncScheduler(AsyncAction);
|
|
1811
|
+
|
|
1812
|
+
// node_modules/rxjs/dist/esm5/internal/operators/debounceTime.js
|
|
1813
|
+
function debounceTime(dueTime, scheduler) {
|
|
1814
|
+
if (scheduler === undefined) {
|
|
1815
|
+
scheduler = asyncScheduler;
|
|
1816
|
+
}
|
|
1817
|
+
return operate(function(source, subscriber) {
|
|
1818
|
+
var activeTask = null;
|
|
1819
|
+
var lastValue = null;
|
|
1820
|
+
var lastTime = null;
|
|
1821
|
+
var emit = function() {
|
|
1822
|
+
if (activeTask) {
|
|
1823
|
+
activeTask.unsubscribe();
|
|
1824
|
+
activeTask = null;
|
|
1825
|
+
var value = lastValue;
|
|
1826
|
+
lastValue = null;
|
|
1827
|
+
subscriber.next(value);
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
function emitWhenIdle() {
|
|
1831
|
+
var targetTime = lastTime + dueTime;
|
|
1832
|
+
var now = scheduler.now();
|
|
1833
|
+
if (now < targetTime) {
|
|
1834
|
+
activeTask = this.schedule(undefined, targetTime - now);
|
|
1835
|
+
subscriber.add(activeTask);
|
|
1836
|
+
return;
|
|
1837
|
+
}
|
|
1838
|
+
emit();
|
|
1839
|
+
}
|
|
1840
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
|
1841
|
+
lastValue = value;
|
|
1842
|
+
lastTime = scheduler.now();
|
|
1843
|
+
if (!activeTask) {
|
|
1844
|
+
activeTask = scheduler.schedule(emitWhenIdle, dueTime);
|
|
1845
|
+
subscriber.add(activeTask);
|
|
1846
|
+
}
|
|
1847
|
+
}, function() {
|
|
1848
|
+
emit();
|
|
1849
|
+
subscriber.complete();
|
|
1850
|
+
}, undefined, function() {
|
|
1851
|
+
lastValue = activeTask = null;
|
|
1852
|
+
}));
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1621
1855
|
// node_modules/rxjs/dist/esm5/internal/operators/filter.js
|
|
1622
1856
|
function filter(predicate, thisArg) {
|
|
1623
1857
|
return operate(function(source, subscriber) {
|
|
@@ -1650,14 +1884,6 @@ function pairwise() {
|
|
|
1650
1884
|
}));
|
|
1651
1885
|
});
|
|
1652
1886
|
}
|
|
1653
|
-
// node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js
|
|
1654
|
-
var dateTimestampProvider = {
|
|
1655
|
-
now: function() {
|
|
1656
|
-
return (dateTimestampProvider.delegate || Date).now();
|
|
1657
|
-
},
|
|
1658
|
-
delegate: undefined
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
1887
|
// node_modules/rxjs/dist/esm5/internal/ReplaySubject.js
|
|
1662
1888
|
var ReplaySubject = function(_super) {
|
|
1663
1889
|
__extends(ReplaySubject2, _super);
|
|
@@ -1907,6 +2133,7 @@ class LivequeryCollection {
|
|
|
1907
2133
|
#keys = new Map;
|
|
1908
2134
|
#indexes;
|
|
1909
2135
|
#core;
|
|
2136
|
+
#filters = new Subject;
|
|
1910
2137
|
ref;
|
|
1911
2138
|
items;
|
|
1912
2139
|
summary;
|
|
@@ -1937,8 +2164,8 @@ class LivequeryCollection {
|
|
|
1937
2164
|
return;
|
|
1938
2165
|
this.ref = ref;
|
|
1939
2166
|
this.#core = core;
|
|
1940
|
-
const timer2 = this.options.lazy !==
|
|
1941
|
-
this.#subscription = core.watch(this.ref, this.id).pipe(finalize(() => {
|
|
2167
|
+
const timer2 = this.options.lazy !== true && setTimeout(() => this.query(this.options.filters || {}));
|
|
2168
|
+
this.#subscription = merge(this.options.debounce ? this.#filters.pipe(debounceTime(this.options.debounce), switchMap((filters) => this.query(filters))) : EMPTY, core.watch(this.ref, this.id).pipe(finalize(() => {
|
|
1942
2169
|
timer2 && clearTimeout(timer2);
|
|
1943
2170
|
}), tap((event) => {
|
|
1944
2171
|
event.summary && this.summary.next(event.summary);
|
|
@@ -2021,7 +2248,7 @@ class LivequeryCollection {
|
|
|
2021
2248
|
chaos && this.items.next(items);
|
|
2022
2249
|
this.loading.next(null);
|
|
2023
2250
|
event.paging && this.paging.next(event.paging);
|
|
2024
|
-
})).subscribe();
|
|
2251
|
+
}))).subscribe();
|
|
2025
2252
|
return this.#subscription;
|
|
2026
2253
|
}
|
|
2027
2254
|
async#query(filters) {
|
|
@@ -2054,6 +2281,9 @@ class LivequeryCollection {
|
|
|
2054
2281
|
this.loading.next("all");
|
|
2055
2282
|
await this.#query(filters);
|
|
2056
2283
|
}
|
|
2284
|
+
async debounceQuery(filters) {
|
|
2285
|
+
this.#filters.next(filters);
|
|
2286
|
+
}
|
|
2057
2287
|
async loadMore() {
|
|
2058
2288
|
const next = this.paging.value.next;
|
|
2059
2289
|
if (!next)
|
|
@@ -2163,7 +2393,6 @@ class LivequeryCore {
|
|
|
2163
2393
|
cache.set(key, query);
|
|
2164
2394
|
return query;
|
|
2165
2395
|
}), mergeMap(($) => $), map(({ result }, index) => {
|
|
2166
|
-
result.error && collection.o.error(result.error);
|
|
2167
2396
|
collection.o.next({
|
|
2168
2397
|
...result,
|
|
2169
2398
|
from: index === 0 ? "query" : "realtime"
|
|
@@ -2518,5 +2747,5 @@ export {
|
|
|
2518
2747
|
LivequeryCollection
|
|
2519
2748
|
};
|
|
2520
2749
|
|
|
2521
|
-
//# debugId=
|
|
2750
|
+
//# debugId=15C911E72000AF4C64756E2164756E21
|
|
2522
2751
|
//# sourceMappingURL=index.js.map
|