@dereekb/rxjs 11.0.0 → 11.0.2
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/index.cjs.js +113 -85
- package/index.esm.js +115 -71
- package/package.json +1 -1
- package/src/lib/filter/filter.map.d.ts +4 -2
- package/src/lib/iterator/iteration.d.ts +6 -2
- package/src/lib/iterator/iteration.mapped.d.ts +2 -4
- package/src/lib/iterator/iteration.mapped.page.d.ts +8 -10
- package/src/lib/iterator/iterator.page.d.ts +17 -12
- package/src/lib/work/work.instance.d.ts +6 -4
package/index.cjs.js
CHANGED
|
@@ -1918,12 +1918,18 @@ class FilterMap {
|
|
|
1918
1918
|
}
|
|
1919
1919
|
class FilterMapKeyInstance {
|
|
1920
1920
|
constructor(dbxFilterMap, key) {
|
|
1921
|
-
this.
|
|
1922
|
-
this.
|
|
1921
|
+
this._dbxFilterMap = void 0;
|
|
1922
|
+
this._key = void 0;
|
|
1923
1923
|
this.filter$ = void 0;
|
|
1924
|
-
this.
|
|
1925
|
-
this.
|
|
1926
|
-
this.filter$ = this.
|
|
1924
|
+
this._dbxFilterMap = dbxFilterMap;
|
|
1925
|
+
this._key = key;
|
|
1926
|
+
this.filter$ = this._dbxFilterMap.filterForKey(this._key);
|
|
1927
|
+
}
|
|
1928
|
+
get dbxFilterMap() {
|
|
1929
|
+
return this._dbxFilterMap;
|
|
1930
|
+
}
|
|
1931
|
+
get key() {
|
|
1932
|
+
return this._key;
|
|
1927
1933
|
}
|
|
1928
1934
|
initWithFilter(filterObs) {
|
|
1929
1935
|
this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
|
|
@@ -1934,15 +1940,21 @@ class FilterMapKeyInstance {
|
|
|
1934
1940
|
}
|
|
1935
1941
|
class FilterMapItem {
|
|
1936
1942
|
constructor(dbxFilterMap, key) {
|
|
1937
|
-
this.
|
|
1938
|
-
this.
|
|
1943
|
+
this._dbxFilterMap = void 0;
|
|
1944
|
+
this._key = void 0;
|
|
1939
1945
|
this._i = 0;
|
|
1940
1946
|
this._source = new FilterSourceInstance();
|
|
1941
1947
|
this._obs = new rxjs.BehaviorSubject([]);
|
|
1942
|
-
this.
|
|
1948
|
+
this._obs$ = this._obs.pipe(rxjs.switchMap(x => rxjs.merge(...x.map(y => y.obs))), rxjs.distinctUntilChanged());
|
|
1943
1949
|
this.filter$ = this._source.initialFilter$;
|
|
1944
|
-
this.
|
|
1945
|
-
this.
|
|
1950
|
+
this._dbxFilterMap = dbxFilterMap;
|
|
1951
|
+
this._key = key;
|
|
1952
|
+
}
|
|
1953
|
+
get dbxFilterMap() {
|
|
1954
|
+
return this._dbxFilterMap;
|
|
1955
|
+
}
|
|
1956
|
+
get key() {
|
|
1957
|
+
return this._key;
|
|
1946
1958
|
}
|
|
1947
1959
|
setDefaultFilterObs(obs) {
|
|
1948
1960
|
this._source.setDefaultFilter(obs);
|
|
@@ -1965,7 +1977,7 @@ class FilterMapItem {
|
|
|
1965
1977
|
/**
|
|
1966
1978
|
* MapItem uses the behavior of the DefaultFilterSource to provide a default filter value.
|
|
1967
1979
|
*/
|
|
1968
|
-
this._source.initWithFilter(this.
|
|
1980
|
+
this._source.initWithFilter(this._obs$);
|
|
1969
1981
|
}
|
|
1970
1982
|
}
|
|
1971
1983
|
}
|
|
@@ -3200,8 +3212,8 @@ function iterationHasNextAndCanLoadMore(iteration) {
|
|
|
3200
3212
|
}
|
|
3201
3213
|
function iteratorNextPageUntilMaxPageLoadLimit(iterator, defaultLimit = 100) {
|
|
3202
3214
|
return iteratorNextPageUntilPage(iterator, () => {
|
|
3203
|
-
var _iterator$
|
|
3204
|
-
const limit = (_iterator$
|
|
3215
|
+
var _iterator$getMaxPageL;
|
|
3216
|
+
const limit = (_iterator$getMaxPageL = iterator.getMaxPageLoadLimit()) != null ? _iterator$getMaxPageL : defaultLimit;
|
|
3205
3217
|
if (util.isMaybeNot(limit)) {
|
|
3206
3218
|
throw new Error('iteratorNextPageUntilMaxPageLoadLimit() failed. There was no maximum defined.');
|
|
3207
3219
|
}
|
|
@@ -3220,9 +3232,9 @@ function iteratorNextPageUntilMaxPageLoadLimit(iterator, defaultLimit = 100) {
|
|
|
3220
3232
|
function iteratorNextPageUntilPage(iteration, page) {
|
|
3221
3233
|
const getPageLimit = util.asGetter(page);
|
|
3222
3234
|
function checkPageLimit(page) {
|
|
3223
|
-
var _iteration$
|
|
3235
|
+
var _iteration$getMaxPage;
|
|
3224
3236
|
const pageLimit = getPageLimit();
|
|
3225
|
-
const maxLimit = Math.min(pageLimit, (_iteration$
|
|
3237
|
+
const maxLimit = Math.min(pageLimit, (_iteration$getMaxPage = iteration.getMaxPageLoadLimit()) != null ? _iteration$getMaxPage : Number.MAX_SAFE_INTEGER);
|
|
3226
3238
|
return page + 1 < maxLimit;
|
|
3227
3239
|
}
|
|
3228
3240
|
return new Promise((resolve, reject) => {
|
|
@@ -5061,32 +5073,6 @@ function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
|
|
|
5061
5073
|
return pageItemAccumulator.itemIteration.latestLoadedPage$;
|
|
5062
5074
|
}
|
|
5063
5075
|
|
|
5064
|
-
class MappedItemIterationInstance {
|
|
5065
|
-
constructor(itemIterator, config) {
|
|
5066
|
-
this.itemIterator = void 0;
|
|
5067
|
-
this.config = void 0;
|
|
5068
|
-
this.hasNext$ = void 0;
|
|
5069
|
-
this.canLoadMore$ = void 0;
|
|
5070
|
-
this.firstState$ = void 0;
|
|
5071
|
-
this.latestState$ = void 0;
|
|
5072
|
-
this.currentState$ = void 0;
|
|
5073
|
-
this.itemIterator = itemIterator;
|
|
5074
|
-
this.config = config;
|
|
5075
|
-
this.hasNext$ = this.itemIterator.hasNext$;
|
|
5076
|
-
this.canLoadMore$ = this.itemIterator.canLoadMore$;
|
|
5077
|
-
this.firstState$ = this.itemIterator.firstState$.pipe(rxjs.map(state => mapLoadingStateResults(state, this.config)), rxjs.shareReplay(1));
|
|
5078
|
-
this.latestState$ = this.itemIterator.latestState$.pipe(rxjs.map(state => mapLoadingStateResults(state, this.config)), rxjs.shareReplay(1));
|
|
5079
|
-
this.currentState$ = this.itemIterator.currentState$.pipe(rxjs.map(state => mapLoadingStateResults(state, this.config)), rxjs.shareReplay(1));
|
|
5080
|
-
}
|
|
5081
|
-
next(request) {
|
|
5082
|
-
return this.itemIterator.next(request);
|
|
5083
|
-
}
|
|
5084
|
-
destroy() {
|
|
5085
|
-
if (this.config.forwardDestroy !== false) {
|
|
5086
|
-
this.itemIterator.destroy();
|
|
5087
|
-
}
|
|
5088
|
-
}
|
|
5089
|
-
}
|
|
5090
5076
|
/**
|
|
5091
5077
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
5092
5078
|
*
|
|
@@ -5094,29 +5080,34 @@ class MappedItemIterationInstance {
|
|
|
5094
5080
|
* @param config
|
|
5095
5081
|
* @returns
|
|
5096
5082
|
*/
|
|
5097
|
-
function mapItemIteration(
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
get maxPageLoadLimit() {
|
|
5111
|
-
return this.itemIterator.maxPageLoadLimit;
|
|
5112
|
-
}
|
|
5113
|
-
set maxPageLoadLimit(maxPageLoadLimit) {
|
|
5114
|
-
this.itemIterator.maxPageLoadLimit = maxPageLoadLimit;
|
|
5115
|
-
}
|
|
5116
|
-
nextPage(request) {
|
|
5117
|
-
return this.itemIterator.nextPage(request);
|
|
5083
|
+
function mapItemIteration(itemIterator, config) {
|
|
5084
|
+
const hasNext$ = itemIterator.hasNext$;
|
|
5085
|
+
const canLoadMore$ = itemIterator.canLoadMore$;
|
|
5086
|
+
const firstState$ = itemIterator.firstState$.pipe(rxjs.map(state => mapLoadingStateResults(state, config)), rxjs.shareReplay(1));
|
|
5087
|
+
const latestState$ = itemIterator.latestState$.pipe(rxjs.map(state => mapLoadingStateResults(state, config)), rxjs.shareReplay(1));
|
|
5088
|
+
const currentState$ = itemIterator.currentState$.pipe(rxjs.map(state => mapLoadingStateResults(state, config)), rxjs.shareReplay(1));
|
|
5089
|
+
function next(request) {
|
|
5090
|
+
return itemIterator.next(request);
|
|
5091
|
+
}
|
|
5092
|
+
function destroy() {
|
|
5093
|
+
if (config.forwardDestroy !== false) {
|
|
5094
|
+
itemIterator.destroy();
|
|
5095
|
+
}
|
|
5118
5096
|
}
|
|
5097
|
+
const result = {
|
|
5098
|
+
itemIterator,
|
|
5099
|
+
config,
|
|
5100
|
+
hasNext$,
|
|
5101
|
+
canLoadMore$,
|
|
5102
|
+
firstState$,
|
|
5103
|
+
latestState$,
|
|
5104
|
+
currentState$,
|
|
5105
|
+
next,
|
|
5106
|
+
destroy
|
|
5107
|
+
};
|
|
5108
|
+
return result;
|
|
5119
5109
|
}
|
|
5110
|
+
|
|
5120
5111
|
/**
|
|
5121
5112
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
5122
5113
|
*
|
|
@@ -5124,9 +5115,26 @@ class MappedPageItemIterationInstance extends MappedItemIterationInstance {
|
|
|
5124
5115
|
* @param config
|
|
5125
5116
|
* @returns
|
|
5126
5117
|
*/
|
|
5127
|
-
function
|
|
5128
|
-
|
|
5118
|
+
function mappedPageItemIteration(itemIteration, config) {
|
|
5119
|
+
function nextPage(request) {
|
|
5120
|
+
return itemIteration.nextPage(request);
|
|
5121
|
+
}
|
|
5122
|
+
return Object.assign({}, mapItemIteration(itemIteration, config), {
|
|
5123
|
+
latestLoadedPage$: itemIteration.latestLoadedPage$,
|
|
5124
|
+
getMaxPageLoadLimit() {
|
|
5125
|
+
return itemIteration.getMaxPageLoadLimit();
|
|
5126
|
+
},
|
|
5127
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5128
|
+
itemIteration.setMaxPageLoadLimit(maxPageLoadLimit);
|
|
5129
|
+
},
|
|
5130
|
+
nextPage
|
|
5131
|
+
});
|
|
5129
5132
|
}
|
|
5133
|
+
// MARK: Compat
|
|
5134
|
+
/**
|
|
5135
|
+
* @deprecated use mappedPageItemIteration instead.
|
|
5136
|
+
*/
|
|
5137
|
+
const mapPageItemIteration = mappedPageItemIteration;
|
|
5130
5138
|
|
|
5131
5139
|
// MARK: Iterator
|
|
5132
5140
|
/**
|
|
@@ -5159,16 +5167,25 @@ function _async(f) {
|
|
|
5159
5167
|
}
|
|
5160
5168
|
const DEFAULT_ITEM_PAGE_ITERATOR_MAX = 100;
|
|
5161
5169
|
class ItemPageIterator {
|
|
5170
|
+
constructor(delegate) {
|
|
5171
|
+
this._delegate = void 0;
|
|
5172
|
+
this._maxPageLoadLimit = void 0;
|
|
5173
|
+
this._delegate = delegate;
|
|
5174
|
+
}
|
|
5175
|
+
get delegate() {
|
|
5176
|
+
return this._delegate;
|
|
5177
|
+
}
|
|
5162
5178
|
get maxPageLoadLimit() {
|
|
5163
5179
|
return this._maxPageLoadLimit;
|
|
5164
5180
|
}
|
|
5165
5181
|
set maxPageLoadLimit(maxPageLoadLimit) {
|
|
5166
5182
|
this._maxPageLoadLimit = maxPageLoadLimit;
|
|
5167
5183
|
}
|
|
5168
|
-
|
|
5169
|
-
this.
|
|
5170
|
-
|
|
5171
|
-
|
|
5184
|
+
getMaxPageLoadLimit() {
|
|
5185
|
+
return this.maxPageLoadLimit;
|
|
5186
|
+
}
|
|
5187
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5188
|
+
this._maxPageLoadLimit = maxPageLoadLimit;
|
|
5172
5189
|
}
|
|
5173
5190
|
/**
|
|
5174
5191
|
* Creates a new instance based on the input config.
|
|
@@ -5185,9 +5202,9 @@ class ItemPageIterator {
|
|
|
5185
5202
|
*/
|
|
5186
5203
|
class ItemPageIterationInstance {
|
|
5187
5204
|
constructor(iterator, config) {
|
|
5188
|
-
var
|
|
5189
|
-
this.
|
|
5190
|
-
this.
|
|
5205
|
+
var _config$maxPageLoadLi;
|
|
5206
|
+
this._iterator = void 0;
|
|
5207
|
+
this._config = void 0;
|
|
5191
5208
|
/**
|
|
5192
5209
|
* Used for triggering loading of more content.
|
|
5193
5210
|
*/
|
|
@@ -5199,9 +5216,9 @@ class ItemPageIterationInstance {
|
|
|
5199
5216
|
this.state$ = this._next.pipe(rxjs.delay(0), rxjs.exhaustMap(request => rxjs.combineLatest([this.hasNextAndCanLoadMore$, this._lastFinishedPageResultState$]).pipe(rxjs.first(), rxjs.map(([hasNextAndCanLoadMore, prevResult]) => [itemPageIteratorShouldLoadNextPage(request, hasNextAndCanLoadMore, prevResult), prevResult]), rxjs.mergeMap(([shouldLoadNextPage, prevResult]) => {
|
|
5200
5217
|
if (shouldLoadNextPage) {
|
|
5201
5218
|
const nextPageNumber = nextIteratorPageNumber(prevResult); // retry number if error occured
|
|
5202
|
-
const page = util.filteredPage(nextPageNumber, this.
|
|
5203
|
-
const iteratorResultObs = this.
|
|
5204
|
-
iteratorConfig: this.
|
|
5219
|
+
const page = util.filteredPage(nextPageNumber, this._config);
|
|
5220
|
+
const iteratorResultObs = this._iterator.delegate.loadItemsForPage({
|
|
5221
|
+
iteratorConfig: this._config,
|
|
5205
5222
|
page: nextPageNumber,
|
|
5206
5223
|
lastItem$: this._lastFinishedPageResultItem$,
|
|
5207
5224
|
lastResult$: this._lastFinishedPageResult$,
|
|
@@ -5336,15 +5353,21 @@ class ItemPageIterationInstance {
|
|
|
5336
5353
|
this.firstState$ = this.firstPageResultState$.pipe(mapItemPageLoadingStateFromResultPageLoadingState(), rxjs.shareReplay(1));
|
|
5337
5354
|
this.latestState$ = this.latestPageResultState$.pipe(mapItemPageLoadingStateFromResultPageLoadingState(), rxjs.shareReplay(1));
|
|
5338
5355
|
this.latestItems$ = this.latestState$.pipe(rxjs.distinctUntilChanged(), rxjs.map(x => x.value), rxjs.shareReplay(1));
|
|
5339
|
-
this.
|
|
5340
|
-
this.
|
|
5341
|
-
this._maxPageLoadLimit.next((
|
|
5356
|
+
this._iterator = iterator;
|
|
5357
|
+
this._config = config;
|
|
5358
|
+
this._maxPageLoadLimit.next((_config$maxPageLoadLi = config.maxPageLoadLimit) != null ? _config$maxPageLoadLi : iterator.getMaxPageLoadLimit());
|
|
5359
|
+
}
|
|
5360
|
+
get iterator() {
|
|
5361
|
+
return this._iterator;
|
|
5362
|
+
}
|
|
5363
|
+
get config() {
|
|
5364
|
+
return this._config;
|
|
5342
5365
|
}
|
|
5343
5366
|
// MARK: PageItemIteration
|
|
5344
|
-
|
|
5367
|
+
getMaxPageLoadLimit() {
|
|
5345
5368
|
return this._maxPageLoadLimit.value;
|
|
5346
5369
|
}
|
|
5347
|
-
|
|
5370
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5348
5371
|
const limit = util.isMaybeNot(maxPageLoadLimit) ? undefined : Math.max(0, Math.ceil(maxPageLoadLimit));
|
|
5349
5372
|
this._maxPageLoadLimit.next(limit);
|
|
5350
5373
|
}
|
|
@@ -5568,8 +5591,8 @@ LockSet.LOCK_SET_CHILD_INDEX_STEPPER = 0;
|
|
|
5568
5591
|
*/
|
|
5569
5592
|
class WorkInstance {
|
|
5570
5593
|
constructor(value, delegate) {
|
|
5571
|
-
this.
|
|
5572
|
-
this.
|
|
5594
|
+
this._value = void 0;
|
|
5595
|
+
this._delegate = void 0;
|
|
5573
5596
|
this._done = false;
|
|
5574
5597
|
this._doneActionBegan = false;
|
|
5575
5598
|
this._result = void 0;
|
|
@@ -5578,14 +5601,20 @@ class WorkInstance {
|
|
|
5578
5601
|
this.loadingState$ = this._loadingState.pipe(filterMaybe());
|
|
5579
5602
|
this._hasStarted$ = this._loadingState.pipe(rxjs.map(x => Boolean(x)), rxjs.shareReplay(1));
|
|
5580
5603
|
this._isComplete$ = this.loadingState$.pipe(rxjs.map(x => isLoadingStateFinishedLoading(x)), rxjs.shareReplay(1));
|
|
5581
|
-
this.
|
|
5582
|
-
this.
|
|
5604
|
+
this._value = value;
|
|
5605
|
+
this._delegate = delegate;
|
|
5583
5606
|
// Schedule to cleanup self once isComplete is true.
|
|
5584
5607
|
this.result$.subscribe(loadingState => {
|
|
5585
5608
|
this._result = loadingState;
|
|
5586
5609
|
this.destroy();
|
|
5587
5610
|
});
|
|
5588
5611
|
}
|
|
5612
|
+
get value() {
|
|
5613
|
+
return this._value;
|
|
5614
|
+
}
|
|
5615
|
+
get delegate() {
|
|
5616
|
+
return this._delegate;
|
|
5617
|
+
}
|
|
5589
5618
|
get hasStarted() {
|
|
5590
5619
|
return this._loadingState.value != null;
|
|
5591
5620
|
}
|
|
@@ -5779,8 +5808,6 @@ exports.ItemPageIterator = ItemPageIterator;
|
|
|
5779
5808
|
exports.ListLoadingStateContextInstance = ListLoadingStateContextInstance;
|
|
5780
5809
|
exports.LoadingStateContextInstance = LoadingStateContextInstance;
|
|
5781
5810
|
exports.LockSet = LockSet;
|
|
5782
|
-
exports.MappedItemIterationInstance = MappedItemIterationInstance;
|
|
5783
|
-
exports.MappedPageItemIterationInstance = MappedPageItemIterationInstance;
|
|
5784
5811
|
exports.MultiSubscriptionObject = MultiSubscriptionObject;
|
|
5785
5812
|
exports.PresetFilterSource = PresetFilterSource;
|
|
5786
5813
|
exports.SimpleLoadingContext = SimpleLoadingContext;
|
|
@@ -5891,6 +5918,7 @@ exports.mapLoadingStateValueWithOperator = mapLoadingStateValueWithOperator;
|
|
|
5891
5918
|
exports.mapMaybe = mapMaybe;
|
|
5892
5919
|
exports.mapMultipleLoadingStateResults = mapMultipleLoadingStateResults;
|
|
5893
5920
|
exports.mapPageItemIteration = mapPageItemIteration;
|
|
5921
|
+
exports.mappedPageItemIteration = mappedPageItemIteration;
|
|
5894
5922
|
exports.maybeValueFromObservableOrValueGetter = maybeValueFromObservableOrValueGetter;
|
|
5895
5923
|
exports.mergeLoadingStateWithError = mergeLoadingStateWithError;
|
|
5896
5924
|
exports.mergeLoadingStateWithLoading = mergeLoadingStateWithLoading;
|
package/index.esm.js
CHANGED
|
@@ -2010,10 +2010,18 @@ class FilterMap {
|
|
|
2010
2010
|
}
|
|
2011
2011
|
class FilterMapKeyInstance {
|
|
2012
2012
|
constructor(dbxFilterMap, key) {
|
|
2013
|
-
this.
|
|
2014
|
-
this.
|
|
2013
|
+
this._dbxFilterMap = void 0;
|
|
2014
|
+
this._key = void 0;
|
|
2015
2015
|
this.filter$ = void 0;
|
|
2016
|
-
this.
|
|
2016
|
+
this._dbxFilterMap = dbxFilterMap;
|
|
2017
|
+
this._key = key;
|
|
2018
|
+
this.filter$ = this._dbxFilterMap.filterForKey(this._key);
|
|
2019
|
+
}
|
|
2020
|
+
get dbxFilterMap() {
|
|
2021
|
+
return this._dbxFilterMap;
|
|
2022
|
+
}
|
|
2023
|
+
get key() {
|
|
2024
|
+
return this._key;
|
|
2017
2025
|
}
|
|
2018
2026
|
initWithFilter(filterObs) {
|
|
2019
2027
|
this.dbxFilterMap.addDefaultFilterObs(this.key, filterObs);
|
|
@@ -2024,13 +2032,21 @@ class FilterMapKeyInstance {
|
|
|
2024
2032
|
}
|
|
2025
2033
|
class FilterMapItem {
|
|
2026
2034
|
constructor(dbxFilterMap, key) {
|
|
2027
|
-
this.
|
|
2028
|
-
this.
|
|
2035
|
+
this._dbxFilterMap = void 0;
|
|
2036
|
+
this._key = void 0;
|
|
2029
2037
|
this._i = 0;
|
|
2030
2038
|
this._source = new FilterSourceInstance();
|
|
2031
2039
|
this._obs = new BehaviorSubject([]);
|
|
2032
|
-
this.
|
|
2040
|
+
this._obs$ = this._obs.pipe(switchMap(x => merge(...x.map(y => y.obs))), distinctUntilChanged());
|
|
2033
2041
|
this.filter$ = this._source.initialFilter$;
|
|
2042
|
+
this._dbxFilterMap = dbxFilterMap;
|
|
2043
|
+
this._key = key;
|
|
2044
|
+
}
|
|
2045
|
+
get dbxFilterMap() {
|
|
2046
|
+
return this._dbxFilterMap;
|
|
2047
|
+
}
|
|
2048
|
+
get key() {
|
|
2049
|
+
return this._key;
|
|
2034
2050
|
}
|
|
2035
2051
|
setDefaultFilterObs(obs) {
|
|
2036
2052
|
this._source.setDefaultFilter(obs);
|
|
@@ -2053,7 +2069,7 @@ class FilterMapItem {
|
|
|
2053
2069
|
/**
|
|
2054
2070
|
* MapItem uses the behavior of the DefaultFilterSource to provide a default filter value.
|
|
2055
2071
|
*/
|
|
2056
|
-
this._source.initWithFilter(this.
|
|
2072
|
+
this._source.initWithFilter(this._obs$);
|
|
2057
2073
|
}
|
|
2058
2074
|
}
|
|
2059
2075
|
}
|
|
@@ -3309,8 +3325,8 @@ function iterationHasNextAndCanLoadMore(iteration) {
|
|
|
3309
3325
|
*/
|
|
3310
3326
|
function iteratorNextPageUntilMaxPageLoadLimit(iterator, defaultLimit = 100) {
|
|
3311
3327
|
return iteratorNextPageUntilPage(iterator, () => {
|
|
3312
|
-
var _iterator$
|
|
3313
|
-
const limit = (_iterator$
|
|
3328
|
+
var _iterator$getMaxPageL;
|
|
3329
|
+
const limit = (_iterator$getMaxPageL = iterator.getMaxPageLoadLimit()) != null ? _iterator$getMaxPageL : defaultLimit;
|
|
3314
3330
|
if (isMaybeNot(limit)) {
|
|
3315
3331
|
throw new Error('iteratorNextPageUntilMaxPageLoadLimit() failed. There was no maximum defined.');
|
|
3316
3332
|
}
|
|
@@ -3330,9 +3346,9 @@ function iteratorNextPageUntilMaxPageLoadLimit(iterator, defaultLimit = 100) {
|
|
|
3330
3346
|
function iteratorNextPageUntilPage(iteration, page) {
|
|
3331
3347
|
const getPageLimit = asGetter(page);
|
|
3332
3348
|
function checkPageLimit(page) {
|
|
3333
|
-
var _iteration$
|
|
3349
|
+
var _iteration$getMaxPage;
|
|
3334
3350
|
const pageLimit = getPageLimit();
|
|
3335
|
-
const maxLimit = Math.min(pageLimit, (_iteration$
|
|
3351
|
+
const maxLimit = Math.min(pageLimit, (_iteration$getMaxPage = iteration.getMaxPageLoadLimit()) != null ? _iteration$getMaxPage : Number.MAX_SAFE_INTEGER);
|
|
3336
3352
|
return page + 1 < maxLimit;
|
|
3337
3353
|
}
|
|
3338
3354
|
return new Promise((resolve, reject) => {
|
|
@@ -5395,31 +5411,6 @@ function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
|
|
|
5395
5411
|
* An object that maps loading states from one mapping to another.
|
|
5396
5412
|
*/
|
|
5397
5413
|
|
|
5398
|
-
class MappedItemIterationInstance {
|
|
5399
|
-
constructor(itemIterator, config) {
|
|
5400
|
-
this.itemIterator = itemIterator;
|
|
5401
|
-
this.config = config;
|
|
5402
|
-
this.hasNext$ = void 0;
|
|
5403
|
-
this.canLoadMore$ = void 0;
|
|
5404
|
-
this.firstState$ = void 0;
|
|
5405
|
-
this.latestState$ = void 0;
|
|
5406
|
-
this.currentState$ = void 0;
|
|
5407
|
-
this.hasNext$ = this.itemIterator.hasNext$;
|
|
5408
|
-
this.canLoadMore$ = this.itemIterator.canLoadMore$;
|
|
5409
|
-
this.firstState$ = this.itemIterator.firstState$.pipe(map(state => mapLoadingStateResults(state, this.config)), shareReplay(1));
|
|
5410
|
-
this.latestState$ = this.itemIterator.latestState$.pipe(map(state => mapLoadingStateResults(state, this.config)), shareReplay(1));
|
|
5411
|
-
this.currentState$ = this.itemIterator.currentState$.pipe(map(state => mapLoadingStateResults(state, this.config)), shareReplay(1));
|
|
5412
|
-
}
|
|
5413
|
-
next(request) {
|
|
5414
|
-
return this.itemIterator.next(request);
|
|
5415
|
-
}
|
|
5416
|
-
destroy() {
|
|
5417
|
-
if (this.config.forwardDestroy !== false) {
|
|
5418
|
-
this.itemIterator.destroy();
|
|
5419
|
-
}
|
|
5420
|
-
}
|
|
5421
|
-
}
|
|
5422
|
-
|
|
5423
5414
|
/**
|
|
5424
5415
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
5425
5416
|
*
|
|
@@ -5427,8 +5418,32 @@ class MappedItemIterationInstance {
|
|
|
5427
5418
|
* @param config
|
|
5428
5419
|
* @returns
|
|
5429
5420
|
*/
|
|
5430
|
-
function mapItemIteration(
|
|
5431
|
-
|
|
5421
|
+
function mapItemIteration(itemIterator, config) {
|
|
5422
|
+
const hasNext$ = itemIterator.hasNext$;
|
|
5423
|
+
const canLoadMore$ = itemIterator.canLoadMore$;
|
|
5424
|
+
const firstState$ = itemIterator.firstState$.pipe(map(state => mapLoadingStateResults(state, config)), shareReplay(1));
|
|
5425
|
+
const latestState$ = itemIterator.latestState$.pipe(map(state => mapLoadingStateResults(state, config)), shareReplay(1));
|
|
5426
|
+
const currentState$ = itemIterator.currentState$.pipe(map(state => mapLoadingStateResults(state, config)), shareReplay(1));
|
|
5427
|
+
function next(request) {
|
|
5428
|
+
return itemIterator.next(request);
|
|
5429
|
+
}
|
|
5430
|
+
function destroy() {
|
|
5431
|
+
if (config.forwardDestroy !== false) {
|
|
5432
|
+
itemIterator.destroy();
|
|
5433
|
+
}
|
|
5434
|
+
}
|
|
5435
|
+
const result = {
|
|
5436
|
+
itemIterator,
|
|
5437
|
+
config,
|
|
5438
|
+
hasNext$,
|
|
5439
|
+
canLoadMore$,
|
|
5440
|
+
firstState$,
|
|
5441
|
+
latestState$,
|
|
5442
|
+
currentState$,
|
|
5443
|
+
next,
|
|
5444
|
+
destroy
|
|
5445
|
+
};
|
|
5446
|
+
return result;
|
|
5432
5447
|
}
|
|
5433
5448
|
|
|
5434
5449
|
/**
|
|
@@ -5438,22 +5453,6 @@ function mapItemIteration(itemIteration, config) {
|
|
|
5438
5453
|
/**
|
|
5439
5454
|
* MappedItemIterationInstance extension that implements PageItemIteration.
|
|
5440
5455
|
*/
|
|
5441
|
-
class MappedPageItemIterationInstance extends MappedItemIterationInstance {
|
|
5442
|
-
constructor(...args) {
|
|
5443
|
-
super(...args);
|
|
5444
|
-
this.latestLoadedPage$ = this.itemIterator.latestLoadedPage$;
|
|
5445
|
-
}
|
|
5446
|
-
// MARK: PageItemIteration
|
|
5447
|
-
get maxPageLoadLimit() {
|
|
5448
|
-
return this.itemIterator.maxPageLoadLimit;
|
|
5449
|
-
}
|
|
5450
|
-
set maxPageLoadLimit(maxPageLoadLimit) {
|
|
5451
|
-
this.itemIterator.maxPageLoadLimit = maxPageLoadLimit;
|
|
5452
|
-
}
|
|
5453
|
-
nextPage(request) {
|
|
5454
|
-
return this.itemIterator.nextPage(request);
|
|
5455
|
-
}
|
|
5456
|
-
}
|
|
5457
5456
|
|
|
5458
5457
|
/**
|
|
5459
5458
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
@@ -5462,10 +5461,28 @@ class MappedPageItemIterationInstance extends MappedItemIterationInstance {
|
|
|
5462
5461
|
* @param config
|
|
5463
5462
|
* @returns
|
|
5464
5463
|
*/
|
|
5465
|
-
function
|
|
5466
|
-
|
|
5464
|
+
function mappedPageItemIteration(itemIteration, config) {
|
|
5465
|
+
function nextPage(request) {
|
|
5466
|
+
return itemIteration.nextPage(request);
|
|
5467
|
+
}
|
|
5468
|
+
return Object.assign({}, mapItemIteration(itemIteration, config), {
|
|
5469
|
+
latestLoadedPage$: itemIteration.latestLoadedPage$,
|
|
5470
|
+
getMaxPageLoadLimit() {
|
|
5471
|
+
return itemIteration.getMaxPageLoadLimit();
|
|
5472
|
+
},
|
|
5473
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5474
|
+
itemIteration.setMaxPageLoadLimit(maxPageLoadLimit);
|
|
5475
|
+
},
|
|
5476
|
+
nextPage
|
|
5477
|
+
});
|
|
5467
5478
|
}
|
|
5468
5479
|
|
|
5480
|
+
// MARK: Compat
|
|
5481
|
+
/**
|
|
5482
|
+
* @deprecated use mappedPageItemIteration instead.
|
|
5483
|
+
*/
|
|
5484
|
+
const mapPageItemIteration = mappedPageItemIteration;
|
|
5485
|
+
|
|
5469
5486
|
// MARK: Iterator
|
|
5470
5487
|
/**
|
|
5471
5488
|
* Default number of pages that can be loaded.
|
|
@@ -5476,15 +5493,25 @@ const DEFAULT_ITEM_PAGE_ITERATOR_MAX = 100;
|
|
|
5476
5493
|
* Used for generating new iterations.
|
|
5477
5494
|
*/
|
|
5478
5495
|
class ItemPageIterator {
|
|
5496
|
+
constructor(delegate) {
|
|
5497
|
+
this._delegate = void 0;
|
|
5498
|
+
this._maxPageLoadLimit = void 0;
|
|
5499
|
+
this._delegate = delegate;
|
|
5500
|
+
}
|
|
5501
|
+
get delegate() {
|
|
5502
|
+
return this._delegate;
|
|
5503
|
+
}
|
|
5479
5504
|
get maxPageLoadLimit() {
|
|
5480
5505
|
return this._maxPageLoadLimit;
|
|
5481
5506
|
}
|
|
5482
5507
|
set maxPageLoadLimit(maxPageLoadLimit) {
|
|
5483
5508
|
this._maxPageLoadLimit = maxPageLoadLimit;
|
|
5484
5509
|
}
|
|
5485
|
-
|
|
5486
|
-
this.
|
|
5487
|
-
|
|
5510
|
+
getMaxPageLoadLimit() {
|
|
5511
|
+
return this.maxPageLoadLimit;
|
|
5512
|
+
}
|
|
5513
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5514
|
+
this._maxPageLoadLimit = maxPageLoadLimit;
|
|
5488
5515
|
}
|
|
5489
5516
|
|
|
5490
5517
|
/**
|
|
@@ -5505,9 +5532,9 @@ class ItemPageIterator {
|
|
|
5505
5532
|
*/
|
|
5506
5533
|
class ItemPageIterationInstance {
|
|
5507
5534
|
constructor(iterator, config) {
|
|
5508
|
-
var
|
|
5509
|
-
this.
|
|
5510
|
-
this.
|
|
5535
|
+
var _config$maxPageLoadLi;
|
|
5536
|
+
this._iterator = void 0;
|
|
5537
|
+
this._config = void 0;
|
|
5511
5538
|
/**
|
|
5512
5539
|
* Used for triggering loading of more content.
|
|
5513
5540
|
*/
|
|
@@ -5519,9 +5546,9 @@ class ItemPageIterationInstance {
|
|
|
5519
5546
|
this.state$ = this._next.pipe(delay(0), exhaustMap(request => combineLatest([this.hasNextAndCanLoadMore$, this._lastFinishedPageResultState$]).pipe(first(), map(([hasNextAndCanLoadMore, prevResult]) => [itemPageIteratorShouldLoadNextPage(request, hasNextAndCanLoadMore, prevResult), prevResult]), mergeMap(([shouldLoadNextPage, prevResult]) => {
|
|
5520
5547
|
if (shouldLoadNextPage) {
|
|
5521
5548
|
const nextPageNumber = nextIteratorPageNumber(prevResult); // retry number if error occured
|
|
5522
|
-
const page = filteredPage(nextPageNumber, this.
|
|
5523
|
-
const iteratorResultObs = this.
|
|
5524
|
-
iteratorConfig: this.
|
|
5549
|
+
const page = filteredPage(nextPageNumber, this._config);
|
|
5550
|
+
const iteratorResultObs = this._iterator.delegate.loadItemsForPage({
|
|
5551
|
+
iteratorConfig: this._config,
|
|
5525
5552
|
page: nextPageNumber,
|
|
5526
5553
|
lastItem$: this._lastFinishedPageResultItem$,
|
|
5527
5554
|
lastResult$: this._lastFinishedPageResult$,
|
|
@@ -5658,13 +5685,21 @@ class ItemPageIterationInstance {
|
|
|
5658
5685
|
this.firstState$ = this.firstPageResultState$.pipe(mapItemPageLoadingStateFromResultPageLoadingState(), shareReplay(1));
|
|
5659
5686
|
this.latestState$ = this.latestPageResultState$.pipe(mapItemPageLoadingStateFromResultPageLoadingState(), shareReplay(1));
|
|
5660
5687
|
this.latestItems$ = this.latestState$.pipe(distinctUntilChanged(), map(x => x.value), shareReplay(1));
|
|
5661
|
-
this.
|
|
5688
|
+
this._iterator = iterator;
|
|
5689
|
+
this._config = config;
|
|
5690
|
+
this._maxPageLoadLimit.next((_config$maxPageLoadLi = config.maxPageLoadLimit) != null ? _config$maxPageLoadLi : iterator.getMaxPageLoadLimit());
|
|
5691
|
+
}
|
|
5692
|
+
get iterator() {
|
|
5693
|
+
return this._iterator;
|
|
5694
|
+
}
|
|
5695
|
+
get config() {
|
|
5696
|
+
return this._config;
|
|
5662
5697
|
}
|
|
5663
5698
|
// MARK: PageItemIteration
|
|
5664
|
-
|
|
5699
|
+
getMaxPageLoadLimit() {
|
|
5665
5700
|
return this._maxPageLoadLimit.value;
|
|
5666
5701
|
}
|
|
5667
|
-
|
|
5702
|
+
setMaxPageLoadLimit(maxPageLoadLimit) {
|
|
5668
5703
|
const limit = isMaybeNot(maxPageLoadLimit) ? undefined : Math.max(0, Math.ceil(maxPageLoadLimit));
|
|
5669
5704
|
this._maxPageLoadLimit.next(limit);
|
|
5670
5705
|
}
|
|
@@ -5898,8 +5933,8 @@ LockSet.LOCK_SET_CHILD_INDEX_STEPPER = 0;
|
|
|
5898
5933
|
*/
|
|
5899
5934
|
class WorkInstance {
|
|
5900
5935
|
constructor(value, delegate) {
|
|
5901
|
-
this.
|
|
5902
|
-
this.
|
|
5936
|
+
this._value = void 0;
|
|
5937
|
+
this._delegate = void 0;
|
|
5903
5938
|
this._done = false;
|
|
5904
5939
|
this._doneActionBegan = false;
|
|
5905
5940
|
this._result = void 0;
|
|
@@ -5908,12 +5943,21 @@ class WorkInstance {
|
|
|
5908
5943
|
this.loadingState$ = this._loadingState.pipe(filterMaybe());
|
|
5909
5944
|
this._hasStarted$ = this._loadingState.pipe(map(x => Boolean(x)), shareReplay(1));
|
|
5910
5945
|
this._isComplete$ = this.loadingState$.pipe(map(x => isLoadingStateFinishedLoading(x)), shareReplay(1));
|
|
5946
|
+
this._value = value;
|
|
5947
|
+
this._delegate = delegate;
|
|
5948
|
+
|
|
5911
5949
|
// Schedule to cleanup self once isComplete is true.
|
|
5912
5950
|
this.result$.subscribe(loadingState => {
|
|
5913
5951
|
this._result = loadingState;
|
|
5914
5952
|
this.destroy();
|
|
5915
5953
|
});
|
|
5916
5954
|
}
|
|
5955
|
+
get value() {
|
|
5956
|
+
return this._value;
|
|
5957
|
+
}
|
|
5958
|
+
get delegate() {
|
|
5959
|
+
return this._delegate;
|
|
5960
|
+
}
|
|
5917
5961
|
get hasStarted() {
|
|
5918
5962
|
return this._loadingState.value != null;
|
|
5919
5963
|
}
|
|
@@ -6121,4 +6165,4 @@ function workFactoryForConfigFactory(configFactory) {
|
|
|
6121
6165
|
};
|
|
6122
6166
|
}
|
|
6123
6167
|
|
|
6124
|
-
export { AbstractLoadingStateContextInstance, DEFAULT_ASYNC_PUSHER_THROTTLE, DEFAULT_FACTORY_TIMER_INTERVAL, DEFAULT_ITEM_PAGE_ITERATOR_MAX, DEFAULT_LOCK_SET_TIME_LOCK_KEY, FilterMap, FilterMapKeyInstance, FilterSource, FilterSourceConnector, FilterSourceInstance, ItemPageIterationInstance, ItemPageIterator, ListLoadingStateContextInstance, LoadingStateContextInstance, LoadingStateType, LockSet,
|
|
6168
|
+
export { AbstractLoadingStateContextInstance, DEFAULT_ASYNC_PUSHER_THROTTLE, DEFAULT_FACTORY_TIMER_INTERVAL, DEFAULT_ITEM_PAGE_ITERATOR_MAX, DEFAULT_LOCK_SET_TIME_LOCK_KEY, FilterMap, FilterMapKeyInstance, FilterSource, FilterSourceConnector, FilterSourceInstance, ItemPageIterationInstance, ItemPageIterator, ListLoadingStateContextInstance, LoadingStateContextInstance, LoadingStateType, LockSet, MultiSubscriptionObject, PresetFilterSource, SimpleLoadingContext, SubscriptionObject, ValuesLoadingContext, WorkInstance, accumulatorCurrentPageListLoadingState, accumulatorFlattenPageListLoadingState, allLoadingStatesHaveFinishedLoading, areAllLoadingStatesFinishedLoading, asObservable, asObservableFromGetter, asyncPusher, asyncPusherCache, beginLoading, beginLoadingPage, checkIs, cleanup, cleanupDestroyable, combineLatestFromArrayObsFn, combineLatestFromMapValuesObsFn, combineLatestFromObject, combineLatestMapFrom, combineLoadingStates, combineLoadingStatesStatus, distinctLoadingState, distinctUntilArrayLengthChanges, distinctUntilHasDifferentValues, distinctUntilItemsHaveDifferentValues, distinctUntilItemsValueChanges, distinctUntilKeysChange, distinctUntilMapHasDifferentKeys, distinctUntilModelIdChange, distinctUntilModelKeyChange, distinctUntilObjectKeyChange, distinctUntilObjectValuesChanged, emitAfterDelay, emitDelayObs, errorFromLoadingState, errorOnEmissionsInPeriod, errorPageResult, errorResult, factoryTimer, filterIfObjectValuesUnchanged, filterItemsWithObservableDecision, filterMaybe, filterUnique, filterWithSearchString, flattenAccumulatorResultItemArray, idleLoadingState, incrementingNumberTimer, initialize, invertObservableDecision, isAnyLoadingStateInLoadingState, isErrorLoadingState, isItemPageIteratorResultEndResult, isListLoadingStateEmpty, isListLoadingStateWithEmptyValue, isLoading, isLoadingStateFinishedLoading, isLoadingStateFinishedLoadingWithDefinedValue, isLoadingStateFinishedLoadingWithError, isLoadingStateInErrorState, isLoadingStateInIdleState, isLoadingStateInLoadingState, isLoadingStateInSuccessState, isLoadingStateLoading, isLoadingStateWithDefinedValue, isLoadingStateWithError, isLoadingStateWithStateType, isNot, isPageLoadingStateMetadataEqual, isSuccessLoadingState, itemAccumulator, itemAccumulatorNextPageUntilResultsCount, iterationHasNextAndCanLoadMore, iteratorNextPageUntilMaxPageLoadLimit, iteratorNextPageUntilPage, keyValueMap, lazyFrom, listLoadingStateContext, listLoadingStateIsEmpty, loadingStateContext, loadingStateFromObs, loadingStateHasError, loadingStateHasFinishedLoading, loadingStateHasFinishedLoadingWithError, loadingStateHasFinishedLoadingWithValue, loadingStateHasValue, loadingStateIsIdle, loadingStateIsLoading, loadingStateType, loadingStatesHaveEquivalentMetadata, makeCheckIsFunction, makeMapFilterWithPresetFn, makeReturnIfIsFunction, mapEachAsync, mapFilterWithPreset, mapForEach, mapIf, mapIsListLoadingStateWithEmptyValue, mapItemIteration, mapKeysIntersectionToArray, mapLoadingState, mapLoadingStateResults, mapLoadingStateValueFunction, mapLoadingStateValueWithOperator, mapMaybe, mapMultipleLoadingStateResults, mapPageItemIteration, mappedPageItemIteration, maybeValueFromObservableOrValueGetter, mergeLoadingStateWithError, mergeLoadingStateWithLoading, mergeLoadingStateWithValue, mergeLoadingStates, multiKeyValueMap, onFalseToTrue, onLockSetNextUnlock, onMatchDelta, onTrueToFalse, pageItemAccumulatorCurrentPage, pageLoadingStateFromObs, pipeIf, preventComplete, promiseFromLoadingState, randomDelay, randomDelayWithRandomFunction, returnIfIs, scanBuildArray, scanCount, scanIntoArray, setContainsAllValuesFrom, setContainsAnyValueFrom, setContainsNoValueFrom, skipFirstMaybe, startWithBeginLoading, successPageResult, successResult, switchMapMaybeDefault, switchMapMaybeObs, switchMapObject, switchMapOnBoolean, switchMapToDefault, switchMapWhileFalse, switchMapWhileTrue, tapAfterTimeout, tapFirst, tapLog, tapOnLoadingStateSuccess, tapOnLoadingStateType, throwErrorAfterTimeout, timeoutStartWith, unknownLoadingStatesIsLoading, updatedStateForSetError, updatedStateForSetLoading, updatedStateForSetValue, useAsObservable, useFirst, valueFromFinishedLoadingState, valueFromLoadingState, valueFromObservableOrValue, valueFromObservableOrValueGetter, workFactory, workFactoryForConfigFactory };
|
package/package.json
CHANGED
|
@@ -20,10 +20,12 @@ export declare class FilterMap<F> implements Destroyable {
|
|
|
20
20
|
destroy(): void;
|
|
21
21
|
}
|
|
22
22
|
export declare class FilterMapKeyInstance<F> implements FilterSourceConnector<F>, FilterSource<F> {
|
|
23
|
-
readonly
|
|
24
|
-
readonly
|
|
23
|
+
private readonly _dbxFilterMap;
|
|
24
|
+
private readonly _key;
|
|
25
25
|
readonly filter$: Observable<F>;
|
|
26
26
|
constructor(dbxFilterMap: FilterMap<F>, key: FilterMapKey);
|
|
27
|
+
get dbxFilterMap(): FilterMap<F>;
|
|
28
|
+
get key(): FilterMapKey;
|
|
27
29
|
initWithFilter(filterObs: Observable<F>): void;
|
|
28
30
|
connectWithSource(filterSource: FilterSource<F>): void;
|
|
29
31
|
}
|
|
@@ -52,7 +52,7 @@ export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingS
|
|
|
52
52
|
*/
|
|
53
53
|
export interface PageItemIteration<V = unknown, L extends PageLoadingState<V> = PageLoadingState<V>> extends ItemIteration<V, L> {
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* Returns the maximum number of pages allowed to be loaded.
|
|
56
56
|
*
|
|
57
57
|
* A page of 15 means that pages 0-14 can be loaded, but not page 15.
|
|
58
58
|
*
|
|
@@ -60,7 +60,11 @@ export interface PageItemIteration<V = unknown, L extends PageLoadingState<V> =
|
|
|
60
60
|
*
|
|
61
61
|
* For most cases you should always have a maxPageLoadLimit set to avoid iterating too munknown unused items.
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
getMaxPageLoadLimit(): Maybe<PageNumber>;
|
|
64
|
+
/**
|
|
65
|
+
* Sets the maximum page load limit on the iteration.
|
|
66
|
+
*/
|
|
67
|
+
setMaxPageLoadLimit(maxPageLoadLimit: Maybe<PageNumber>): void;
|
|
64
68
|
/**
|
|
65
69
|
* Attempts to loads the next page of results and returns a promise.
|
|
66
70
|
*
|
|
@@ -17,7 +17,7 @@ export interface MappedItemIterationInstanceMapConfig<O, I, M extends LoadingSta
|
|
|
17
17
|
*/
|
|
18
18
|
forwardDestroy?: boolean;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
20
|
+
export interface MappedItemIterationInstance<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>> extends ItemIteration<O>, Destroyable {
|
|
21
21
|
readonly itemIterator: N;
|
|
22
22
|
readonly config: MappedItemIterationInstanceMapConfig<O, I, M, L>;
|
|
23
23
|
readonly hasNext$: Observable<boolean>;
|
|
@@ -25,9 +25,7 @@ export declare class MappedItemIterationInstance<O, I = unknown, M extends Loadi
|
|
|
25
25
|
readonly firstState$: Observable<M>;
|
|
26
26
|
readonly latestState$: Observable<M>;
|
|
27
27
|
readonly currentState$: Observable<M>;
|
|
28
|
-
constructor(itemIterator: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>);
|
|
29
28
|
next(request?: ItemIteratorNextRequest): void;
|
|
30
|
-
destroy(): void;
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
@@ -36,4 +34,4 @@ export declare class MappedItemIterationInstance<O, I = unknown, M extends Loadi
|
|
|
36
34
|
* @param config
|
|
37
35
|
* @returns
|
|
38
36
|
*/
|
|
39
|
-
export declare function mapItemIteration<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>>(
|
|
37
|
+
export declare function mapItemIteration<O, I = unknown, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>>(itemIterator: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>): MappedItemIterationInstance<O, I, M, L, N>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { type PageLoadingState } from '../loading';
|
|
2
|
-
import { type
|
|
3
|
-
import { type
|
|
4
|
-
import { type MappedItemIteration, MappedItemIterationInstance, type MappedItemIterationInstanceMapConfig } from './iteration.mapped';
|
|
5
|
-
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type PageItemIteration } from './iteration';
|
|
3
|
+
import { type MappedItemIteration, type MappedItemIterationInstance, type MappedItemIterationInstanceMapConfig } from './iteration.mapped';
|
|
6
4
|
/**
|
|
7
5
|
* MappedItemIteration for PageItemIteration
|
|
8
6
|
*/
|
|
@@ -10,11 +8,7 @@ export type MappedPageItemIteration<O, I = unknown, M extends PageLoadingState<O
|
|
|
10
8
|
/**
|
|
11
9
|
* MappedItemIterationInstance extension that implements PageItemIteration.
|
|
12
10
|
*/
|
|
13
|
-
export
|
|
14
|
-
get maxPageLoadLimit(): Maybe<number>;
|
|
15
|
-
set maxPageLoadLimit(maxPageLoadLimit: Maybe<number>);
|
|
16
|
-
readonly latestLoadedPage$: Observable<number>;
|
|
17
|
-
nextPage(request?: ItemIteratorNextRequest): Promise<number>;
|
|
11
|
+
export interface MappedPageItemIterationInstance<O, I = unknown, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>> extends MappedItemIterationInstance<O, I, M, L, N>, PageItemIteration<O, M> {
|
|
18
12
|
}
|
|
19
13
|
/**
|
|
20
14
|
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
@@ -23,4 +17,8 @@ export declare class MappedPageItemIterationInstance<O, I = unknown, M extends P
|
|
|
23
17
|
* @param config
|
|
24
18
|
* @returns
|
|
25
19
|
*/
|
|
26
|
-
export declare function
|
|
20
|
+
export declare function mappedPageItemIteration<O, I = unknown, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>>(itemIteration: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>): MappedPageItemIterationInstance<O, I, M, L, N>;
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated use mappedPageItemIteration instead.
|
|
23
|
+
*/
|
|
24
|
+
export declare const mapPageItemIteration: typeof mappedPageItemIteration;
|
|
@@ -74,11 +74,14 @@ export declare const DEFAULT_ITEM_PAGE_ITERATOR_MAX = 100;
|
|
|
74
74
|
* Used for generating new iterations.
|
|
75
75
|
*/
|
|
76
76
|
export declare class ItemPageIterator<V, F, C extends ItemPageIterationConfig<F> = ItemPageIterationConfig<F>> {
|
|
77
|
-
readonly
|
|
77
|
+
private readonly _delegate;
|
|
78
78
|
protected _maxPageLoadLimit: Maybe<number>;
|
|
79
|
+
constructor(delegate: ItemPageIteratorDelegate<V, F, C>);
|
|
80
|
+
get delegate(): ItemPageIteratorDelegate<V, F, C>;
|
|
79
81
|
get maxPageLoadLimit(): Maybe<number>;
|
|
80
82
|
set maxPageLoadLimit(maxPageLoadLimit: Maybe<number>);
|
|
81
|
-
|
|
83
|
+
getMaxPageLoadLimit(): Maybe<number>;
|
|
84
|
+
setMaxPageLoadLimit(maxPageLoadLimit: Maybe<number>): void;
|
|
82
85
|
/**
|
|
83
86
|
* Creates a new instance based on the input config.
|
|
84
87
|
*
|
|
@@ -91,28 +94,30 @@ export interface ItemPageIterationInstanceState<V> {
|
|
|
91
94
|
/**
|
|
92
95
|
* Used for tracking the start/end of a specific next call.
|
|
93
96
|
*/
|
|
94
|
-
n: number;
|
|
95
|
-
current: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
97
|
+
readonly n: number;
|
|
98
|
+
readonly current: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
96
99
|
/**
|
|
97
100
|
* The first finished state. May not always be the same as firstSuccessful if the first state has an error.
|
|
98
101
|
*/
|
|
99
|
-
firstFinished: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
100
|
-
latestFinished: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
101
|
-
firstSuccessful: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
102
|
-
lastSuccessful: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
102
|
+
readonly firstFinished: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
103
|
+
readonly latestFinished: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
104
|
+
readonly firstSuccessful: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
105
|
+
readonly lastSuccessful: Maybe<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
103
106
|
}
|
|
104
107
|
/**
|
|
105
108
|
* Configured Iterator instance.
|
|
106
109
|
*/
|
|
107
110
|
export declare class ItemPageIterationInstance<V, F, C extends ItemPageIterationConfig<F> = ItemPageIterationConfig<F>> implements PageItemIteration<V, PageLoadingState<V>>, Destroyable {
|
|
108
|
-
readonly
|
|
109
|
-
readonly
|
|
111
|
+
private readonly _iterator;
|
|
112
|
+
private readonly _config;
|
|
110
113
|
/**
|
|
111
114
|
* Used for triggering loading of more content.
|
|
112
115
|
*/
|
|
113
116
|
private readonly _next;
|
|
114
117
|
private readonly _maxPageLoadLimit;
|
|
115
118
|
constructor(iterator: ItemPageIterator<V, F, C>, config: C);
|
|
119
|
+
get iterator(): ItemPageIterator<V, F, C>;
|
|
120
|
+
get config(): C;
|
|
116
121
|
readonly state$: Observable<ItemPageIterationInstanceState<V>>;
|
|
117
122
|
/**
|
|
118
123
|
* Used to track when a next() value changes, or the current changes.
|
|
@@ -160,8 +165,8 @@ export declare class ItemPageIterationInstance<V, F, C extends ItemPageIteration
|
|
|
160
165
|
* The latest page results that has finished loading without an error.
|
|
161
166
|
*/
|
|
162
167
|
readonly latestSuccessfulPageResults$: Observable<PageLoadingState<ItemPageIteratorResult<V>>>;
|
|
163
|
-
|
|
164
|
-
|
|
168
|
+
getMaxPageLoadLimit(): Maybe<number>;
|
|
169
|
+
setMaxPageLoadLimit(maxPageLoadLimit: Maybe<number>): void;
|
|
165
170
|
nextPage(request?: ItemIteratorNextRequest): Promise<number>;
|
|
166
171
|
readonly currentState$: Observable<PageLoadingState<V>>;
|
|
167
172
|
readonly latestLoadedPage$: Observable<PageNumber>;
|
|
@@ -13,17 +13,19 @@ export interface WorkInstanceDelegate<O = unknown> {
|
|
|
13
13
|
* Instance that tracks doing an arbitrary piece of asynchronous work that has an input value and an output value.
|
|
14
14
|
*/
|
|
15
15
|
export declare class WorkInstance<I = unknown, O = unknown> implements Destroyable {
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
16
|
+
private readonly _value;
|
|
17
|
+
private readonly _delegate;
|
|
18
18
|
private _done;
|
|
19
19
|
private _doneActionBegan;
|
|
20
20
|
private _result;
|
|
21
|
-
private _loadingState;
|
|
22
|
-
private _sub;
|
|
21
|
+
private readonly _loadingState;
|
|
22
|
+
private readonly _sub;
|
|
23
23
|
readonly loadingState$: Observable<LoadingState<O>>;
|
|
24
24
|
protected readonly _hasStarted$: Observable<boolean>;
|
|
25
25
|
protected readonly _isComplete$: Observable<boolean>;
|
|
26
26
|
constructor(value: I, delegate: WorkInstanceDelegate<O>);
|
|
27
|
+
get value(): I;
|
|
28
|
+
get delegate(): WorkInstanceDelegate<O>;
|
|
27
29
|
get hasStarted(): boolean;
|
|
28
30
|
get hasStarted$(): Observable<boolean>;
|
|
29
31
|
get isComplete(): boolean;
|