@dereekb/rxjs 10.0.19 → 10.0.21
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 +78 -10
- package/index.esm.js +75 -9
- package/package.json +1 -1
- package/src/lib/iterator/iteration.accumulator.d.ts +20 -1
- package/src/lib/iterator/iteration.accumulator.rxjs.d.ts +7 -0
- package/src/lib/iterator/iteration.d.ts +15 -1
- package/src/lib/iterator/iterator.page.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -3233,16 +3233,21 @@ function iteratorNextPageUntilPage(iteration, page) {
|
|
|
3233
3233
|
const maxLimit = Math.min(pageLimit, (_a = iteration.maxPageLoadLimit) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER);
|
|
3234
3234
|
return page + 1 < maxLimit;
|
|
3235
3235
|
}
|
|
3236
|
-
return new Promise(resolve => {
|
|
3237
|
-
iteration.latestLoadedPage$.pipe(rxjs.first()).subscribe(
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3236
|
+
return new Promise((resolve, reject) => {
|
|
3237
|
+
iteration.latestLoadedPage$.pipe(rxjs.first()).subscribe({
|
|
3238
|
+
next: firstLatestPage => {
|
|
3239
|
+
const promise = util.performTaskLoop({
|
|
3240
|
+
initValue: firstLatestPage,
|
|
3241
|
+
checkContinue: latestPage => checkPageLimit(latestPage),
|
|
3242
|
+
next: () => __awaiter(this, void 0, void 0, function* () {
|
|
3243
|
+
return yield iteration.nextPage();
|
|
3244
|
+
})
|
|
3245
|
+
});
|
|
3246
|
+
resolve(promise);
|
|
3247
|
+
},
|
|
3248
|
+
error: error => {
|
|
3249
|
+
reject(error);
|
|
3250
|
+
}
|
|
3246
3251
|
});
|
|
3247
3252
|
});
|
|
3248
3253
|
}
|
|
@@ -4775,6 +4780,58 @@ function itemAccumulator(itemIteration, mapItem) {
|
|
|
4775
4780
|
}
|
|
4776
4781
|
return new ItemAccumulatorInstance(itemIteration, mapItem);
|
|
4777
4782
|
}
|
|
4783
|
+
/**
|
|
4784
|
+
* Automatically calls next on the accumulator's page item iteration up to the target number of results. Returns the total number of items loaded.
|
|
4785
|
+
*
|
|
4786
|
+
* The promise will reject with an error if an error is encountered.
|
|
4787
|
+
*
|
|
4788
|
+
* @param iteration
|
|
4789
|
+
* @param maxResultsLimit
|
|
4790
|
+
* @returns
|
|
4791
|
+
*/
|
|
4792
|
+
function itemAccumulatorNextPageUntilResultsCount(config) {
|
|
4793
|
+
const {
|
|
4794
|
+
accumulator,
|
|
4795
|
+
maxResultsLimit,
|
|
4796
|
+
countResultsFunction: countResults
|
|
4797
|
+
} = config;
|
|
4798
|
+
const getMaxResultsLimit = util.asGetter(maxResultsLimit);
|
|
4799
|
+
function checkResultsLimit() {
|
|
4800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4801
|
+
const allItems = yield rxjs.firstValueFrom(accumulator.allItems$);
|
|
4802
|
+
const currentCount = yield countResults(allItems);
|
|
4803
|
+
const maxResultsLimit = getMaxResultsLimit();
|
|
4804
|
+
return {
|
|
4805
|
+
shouldContinue: currentCount < maxResultsLimit,
|
|
4806
|
+
currentCount
|
|
4807
|
+
};
|
|
4808
|
+
});
|
|
4809
|
+
}
|
|
4810
|
+
return new Promise((resolve, reject) => {
|
|
4811
|
+
accumulator.allItems$.pipe(rxjs.first(), rxjs.switchMap(allItems => rxjs.from(util.asPromise(countResults(allItems))))).subscribe({
|
|
4812
|
+
next: currentResultsCount => __awaiter(this, void 0, void 0, function* () {
|
|
4813
|
+
const page = yield util.performTaskLoop({
|
|
4814
|
+
initValue: currentResultsCount,
|
|
4815
|
+
checkContinue: () => __awaiter(this, void 0, void 0, function* () {
|
|
4816
|
+
const result = yield checkResultsLimit();
|
|
4817
|
+
currentResultsCount = result.currentCount;
|
|
4818
|
+
return result.shouldContinue;
|
|
4819
|
+
}),
|
|
4820
|
+
next: () => __awaiter(this, void 0, void 0, function* () {
|
|
4821
|
+
return yield accumulator.itemIteration.nextPage();
|
|
4822
|
+
})
|
|
4823
|
+
});
|
|
4824
|
+
resolve({
|
|
4825
|
+
page,
|
|
4826
|
+
resultsCount: currentResultsCount
|
|
4827
|
+
});
|
|
4828
|
+
}),
|
|
4829
|
+
error: error => {
|
|
4830
|
+
reject(error);
|
|
4831
|
+
}
|
|
4832
|
+
});
|
|
4833
|
+
});
|
|
4834
|
+
}
|
|
4778
4835
|
|
|
4779
4836
|
/**
|
|
4780
4837
|
* Used for ItemAccumulators that have an array of results returned per page instead of a single item.
|
|
@@ -4815,6 +4872,15 @@ function accumulatorCurrentPageListLoadingState(accumulator) {
|
|
|
4815
4872
|
mapValue: () => values
|
|
4816
4873
|
})), rxjs.shareReplay(1));
|
|
4817
4874
|
}
|
|
4875
|
+
/**
|
|
4876
|
+
* Returns the latest loaded page number from the input PageItemAccumulator.
|
|
4877
|
+
*
|
|
4878
|
+
* @param pageItemAccumulator
|
|
4879
|
+
* @returns
|
|
4880
|
+
*/
|
|
4881
|
+
function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
|
|
4882
|
+
return pageItemAccumulator.itemIteration.latestLoadedPage$;
|
|
4883
|
+
}
|
|
4818
4884
|
|
|
4819
4885
|
class MappedItemIterationInstance {
|
|
4820
4886
|
constructor(itemIterator, config) {
|
|
@@ -5535,6 +5601,7 @@ exports.isLoading = isLoading;
|
|
|
5535
5601
|
exports.isNot = isNot;
|
|
5536
5602
|
exports.isSuccessLoadingState = isSuccessLoadingState;
|
|
5537
5603
|
exports.itemAccumulator = itemAccumulator;
|
|
5604
|
+
exports.itemAccumulatorNextPageUntilResultsCount = itemAccumulatorNextPageUntilResultsCount;
|
|
5538
5605
|
exports.iterationHasNextAndCanLoadMore = iterationHasNextAndCanLoadMore;
|
|
5539
5606
|
exports.iteratorNextPageUntilMaxPageLoadLimit = iteratorNextPageUntilMaxPageLoadLimit;
|
|
5540
5607
|
exports.iteratorNextPageUntilPage = iteratorNextPageUntilPage;
|
|
@@ -5576,6 +5643,7 @@ exports.onFalseToTrue = onFalseToTrue;
|
|
|
5576
5643
|
exports.onLockSetNextUnlock = onLockSetNextUnlock;
|
|
5577
5644
|
exports.onMatchDelta = onMatchDelta;
|
|
5578
5645
|
exports.onTrueToFalse = onTrueToFalse;
|
|
5646
|
+
exports.pageItemAccumulatorCurrentPage = pageItemAccumulatorCurrentPage;
|
|
5579
5647
|
exports.pageLoadingStateFromObs = pageLoadingStateFromObs;
|
|
5580
5648
|
exports.pipeIf = pipeIf;
|
|
5581
5649
|
exports.preventComplete = preventComplete;
|
package/index.esm.js
CHANGED
|
@@ -3325,14 +3325,19 @@ function iteratorNextPageUntilPage(iteration, page) {
|
|
|
3325
3325
|
const maxLimit = Math.min(pageLimit, (_iteration$maxPageLoa = iteration.maxPageLoadLimit) != null ? _iteration$maxPageLoa : Number.MAX_SAFE_INTEGER);
|
|
3326
3326
|
return page + 1 < maxLimit;
|
|
3327
3327
|
}
|
|
3328
|
-
return new Promise(resolve => {
|
|
3329
|
-
iteration.latestLoadedPage$.pipe(first()).subscribe(
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3328
|
+
return new Promise((resolve, reject) => {
|
|
3329
|
+
iteration.latestLoadedPage$.pipe(first()).subscribe({
|
|
3330
|
+
next: firstLatestPage => {
|
|
3331
|
+
const promise = performTaskLoop({
|
|
3332
|
+
initValue: firstLatestPage,
|
|
3333
|
+
checkContinue: latestPage => checkPageLimit(latestPage),
|
|
3334
|
+
next: async () => await iteration.nextPage()
|
|
3335
|
+
});
|
|
3336
|
+
resolve(promise);
|
|
3337
|
+
},
|
|
3338
|
+
error: error => {
|
|
3339
|
+
reject(error);
|
|
3340
|
+
}
|
|
3336
3341
|
});
|
|
3337
3342
|
});
|
|
3338
3343
|
}
|
|
@@ -5097,6 +5102,57 @@ function itemAccumulator(itemIteration, mapItem) {
|
|
|
5097
5102
|
return new ItemAccumulatorInstance(itemIteration, mapItem);
|
|
5098
5103
|
}
|
|
5099
5104
|
|
|
5105
|
+
// MARK: Utility
|
|
5106
|
+
|
|
5107
|
+
/**
|
|
5108
|
+
* Automatically calls next on the accumulator's page item iteration up to the target number of results. Returns the total number of items loaded.
|
|
5109
|
+
*
|
|
5110
|
+
* The promise will reject with an error if an error is encountered.
|
|
5111
|
+
*
|
|
5112
|
+
* @param iteration
|
|
5113
|
+
* @param maxResultsLimit
|
|
5114
|
+
* @returns
|
|
5115
|
+
*/
|
|
5116
|
+
function itemAccumulatorNextPageUntilResultsCount(config) {
|
|
5117
|
+
const {
|
|
5118
|
+
accumulator,
|
|
5119
|
+
maxResultsLimit,
|
|
5120
|
+
countResultsFunction: countResults
|
|
5121
|
+
} = config;
|
|
5122
|
+
const getMaxResultsLimit = asGetter(maxResultsLimit);
|
|
5123
|
+
async function checkResultsLimit() {
|
|
5124
|
+
const allItems = await firstValueFrom(accumulator.allItems$);
|
|
5125
|
+
const currentCount = await countResults(allItems);
|
|
5126
|
+
const maxResultsLimit = getMaxResultsLimit();
|
|
5127
|
+
return {
|
|
5128
|
+
shouldContinue: currentCount < maxResultsLimit,
|
|
5129
|
+
currentCount
|
|
5130
|
+
};
|
|
5131
|
+
}
|
|
5132
|
+
return new Promise((resolve, reject) => {
|
|
5133
|
+
accumulator.allItems$.pipe(first(), switchMap(allItems => from(asPromise(countResults(allItems))))).subscribe({
|
|
5134
|
+
next: async currentResultsCount => {
|
|
5135
|
+
const page = await performTaskLoop({
|
|
5136
|
+
initValue: currentResultsCount,
|
|
5137
|
+
checkContinue: async () => {
|
|
5138
|
+
const result = await checkResultsLimit();
|
|
5139
|
+
currentResultsCount = result.currentCount;
|
|
5140
|
+
return result.shouldContinue;
|
|
5141
|
+
},
|
|
5142
|
+
next: async () => await accumulator.itemIteration.nextPage()
|
|
5143
|
+
});
|
|
5144
|
+
resolve({
|
|
5145
|
+
page,
|
|
5146
|
+
resultsCount: currentResultsCount
|
|
5147
|
+
});
|
|
5148
|
+
},
|
|
5149
|
+
error: error => {
|
|
5150
|
+
reject(error);
|
|
5151
|
+
}
|
|
5152
|
+
});
|
|
5153
|
+
});
|
|
5154
|
+
}
|
|
5155
|
+
|
|
5100
5156
|
/**
|
|
5101
5157
|
* Used for ItemAccumulators that have an array of results returned per page instead of a single item.
|
|
5102
5158
|
*
|
|
@@ -5139,6 +5195,16 @@ function accumulatorCurrentPageListLoadingState(accumulator) {
|
|
|
5139
5195
|
})), shareReplay(1));
|
|
5140
5196
|
}
|
|
5141
5197
|
|
|
5198
|
+
/**
|
|
5199
|
+
* Returns the latest loaded page number from the input PageItemAccumulator.
|
|
5200
|
+
*
|
|
5201
|
+
* @param pageItemAccumulator
|
|
5202
|
+
* @returns
|
|
5203
|
+
*/
|
|
5204
|
+
function pageItemAccumulatorCurrentPage(pageItemAccumulator) {
|
|
5205
|
+
return pageItemAccumulator.itemIteration.latestLoadedPage$;
|
|
5206
|
+
}
|
|
5207
|
+
|
|
5142
5208
|
/**
|
|
5143
5209
|
* An object that maps loading states from one mapping to another.
|
|
5144
5210
|
*/
|
|
@@ -5839,4 +5905,4 @@ function workFactoryForConfigFactory(configFactory) {
|
|
|
5839
5905
|
};
|
|
5840
5906
|
}
|
|
5841
5907
|
|
|
5842
|
-
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, ItemAccumulatorInstance, ItemPageIterationInstance, ItemPageIterator, ListLoadingStateContextInstance, LoadingStateContextInstance, LoadingStateType, LockSet, MappedItemIterationInstance, MappedPageItemIterationInstance, MultiSubscriptionObject, PresetFilterSource, SimpleLoadingContext, SubscriptionObject, ValuesLoadingContext, WorkInstance, accumulatorCurrentPageListLoadingState, accumulatorFlattenPageListLoadingState, allLoadingStatesHaveFinishedLoading, 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, errorPageResult, errorResult, factoryTimer, filterIfObjectValuesUnchanged, filterItemsWithObservableDecision, filterMaybe, filterUnique, filterWithSearchString, flattenAccumulatorResultItemArray, idleLoadingState, incrementingNumberTimer, initialize, invertObservableDecision, isErrorLoadingState, isItemPageIteratorResultEndResult, isListLoadingStateEmpty, isLoading, isNot, isSuccessLoadingState, itemAccumulator, 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, mapItemIteration, mapKeysIntersectionToArray, mapLoadingState, mapLoadingStateResults, mapLoadingStateValueFunction, mapLoadingStateValueWithOperator, mapMaybe, mapMultipleLoadingStateResults, mapPageItemIteration, maybeValueFromObservableOrValueGetter, mergeLoadingStates, multiKeyValueMap, onFalseToTrue, onLockSetNextUnlock, onMatchDelta, onTrueToFalse, 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 };
|
|
5908
|
+
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, ItemAccumulatorInstance, ItemPageIterationInstance, ItemPageIterator, ListLoadingStateContextInstance, LoadingStateContextInstance, LoadingStateType, LockSet, MappedItemIterationInstance, MappedPageItemIterationInstance, MultiSubscriptionObject, PresetFilterSource, SimpleLoadingContext, SubscriptionObject, ValuesLoadingContext, WorkInstance, accumulatorCurrentPageListLoadingState, accumulatorFlattenPageListLoadingState, allLoadingStatesHaveFinishedLoading, 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, errorPageResult, errorResult, factoryTimer, filterIfObjectValuesUnchanged, filterItemsWithObservableDecision, filterMaybe, filterUnique, filterWithSearchString, flattenAccumulatorResultItemArray, idleLoadingState, incrementingNumberTimer, initialize, invertObservableDecision, isErrorLoadingState, isItemPageIteratorResultEndResult, isListLoadingStateEmpty, isLoading, isNot, 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, mapItemIteration, mapKeysIntersectionToArray, mapLoadingState, mapLoadingStateResults, mapLoadingStateValueFunction, mapLoadingStateValueWithOperator, mapMaybe, mapMultipleLoadingStateResults, mapPageItemIteration, maybeValueFromObservableOrValueGetter, 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
|
-
import { type MapFunctionOutputPair, type Destroyable, type IndexRef } from '@dereekb/util';
|
|
2
|
+
import { type MapFunctionOutputPair, type Destroyable, type IndexRef, type GetterOrValue, type MapFunction, type PromiseOrValue, type Page } from '@dereekb/util';
|
|
3
3
|
import { type ItemIteration, type PageItemIteration } from './iteration';
|
|
4
4
|
import { type LoadingState, type MapLoadingStateValueMapFunction } from '../loading';
|
|
5
5
|
export type ItemAccumulatorMapFunction<O, I> = MapLoadingStateValueMapFunction<O, I>;
|
|
@@ -83,3 +83,22 @@ export declare class ItemAccumulatorInstance<O, I = unknown, N extends ItemItera
|
|
|
83
83
|
*/
|
|
84
84
|
export declare function itemAccumulator<I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N): ItemAccumulatorInstance<I, I, N>;
|
|
85
85
|
export declare function itemAccumulator<O, I, N extends ItemIteration<I> = ItemIteration<I>>(itemIteration: N, mapItem?: ItemAccumulatorMapFunction<O, I>): ItemAccumulatorInstance<O, I, N>;
|
|
86
|
+
export type ItemAccumulatorNextPageUntilResultsCountFunction<O> = MapFunction<O[], PromiseOrValue<number>>;
|
|
87
|
+
export interface ItemAccumulatorNextPageUntilResultsCountConfig<O> {
|
|
88
|
+
readonly accumulator: ItemAccumulator<O, any, PageItemIteration<any>>;
|
|
89
|
+
readonly maxResultsLimit: GetterOrValue<number>;
|
|
90
|
+
readonly countResultsFunction: ItemAccumulatorNextPageUntilResultsCountFunction<O>;
|
|
91
|
+
}
|
|
92
|
+
export interface ItemAccumulatorNextPageUntilResultsCountResult extends Page {
|
|
93
|
+
readonly resultsCount: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Automatically calls next on the accumulator's page item iteration up to the target number of results. Returns the total number of items loaded.
|
|
97
|
+
*
|
|
98
|
+
* The promise will reject with an error if an error is encountered.
|
|
99
|
+
*
|
|
100
|
+
* @param iteration
|
|
101
|
+
* @param maxResultsLimit
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
export declare function itemAccumulatorNextPageUntilResultsCount<O>(config: ItemAccumulatorNextPageUntilResultsCountConfig<O>): Promise<ItemAccumulatorNextPageUntilResultsCountResult>;
|
|
@@ -16,3 +16,10 @@ export declare function accumulatorFlattenPageListLoadingState<T, I = unknown>(a
|
|
|
16
16
|
* A PageListLoadingState that captures all the values that have been loaded so far, and the current loading state of currentPageResult$.
|
|
17
17
|
*/
|
|
18
18
|
export declare function accumulatorCurrentPageListLoadingState<V, I = unknown>(accumulator: PageItemAccumulator<V, I>): Observable<PageListLoadingState<V>>;
|
|
19
|
+
/**
|
|
20
|
+
* Returns the latest loaded page number from the input PageItemAccumulator.
|
|
21
|
+
*
|
|
22
|
+
* @param pageItemAccumulator
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function pageItemAccumulatorCurrentPage(pageItemAccumulator: PageItemAccumulator<any, any>): Observable<number>;
|
|
@@ -14,7 +14,21 @@ export interface ItemIteratorNextRequest {
|
|
|
14
14
|
retry?: boolean;
|
|
15
15
|
}
|
|
16
16
|
export interface ItemIteration<V = unknown, L extends LoadingState<V> = LoadingState<V>> extends Destroyable {
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not there are more items to be loaded.
|
|
19
|
+
*
|
|
20
|
+
* This emits every time a page has finished loading.
|
|
21
|
+
*
|
|
22
|
+
* This will not return false when the max page limit has been reached.
|
|
23
|
+
*/
|
|
17
24
|
readonly hasNext$: Observable<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Whether or not more items can be loaded.
|
|
27
|
+
*
|
|
28
|
+
* Similar to hasNext$ but does not emit until the value changes.
|
|
29
|
+
*
|
|
30
|
+
* This returns false if the max page limit has been reached.
|
|
31
|
+
*/
|
|
18
32
|
readonly canLoadMore$: Observable<boolean>;
|
|
19
33
|
/**
|
|
20
34
|
* The first stable state that has finished loading.
|
|
@@ -50,7 +64,7 @@ export interface PageItemIteration<V = unknown, L extends PageLoadingState<V> =
|
|
|
50
64
|
/**
|
|
51
65
|
* Attempts to loads the next page of results and returns a promise.
|
|
52
66
|
*
|
|
53
|
-
* The promise will return when the next action has completed.
|
|
67
|
+
* The promise will return when the next action has completed, and returns the page number of the loaded page.
|
|
54
68
|
*
|
|
55
69
|
* If the page result ends in an error, this promise will throw that error.
|
|
56
70
|
*
|
|
@@ -165,7 +165,7 @@ export declare class ItemPageIterationInstance<V, F, C extends ItemPageIteration
|
|
|
165
165
|
nextPage(request?: ItemIteratorNextRequest): Promise<number>;
|
|
166
166
|
readonly currentState$: Observable<PageLoadingState<V>>;
|
|
167
167
|
readonly latestLoadedPage$: Observable<PageNumber>;
|
|
168
|
-
readonly numberOfPagesLoaded$: Observable<
|
|
168
|
+
readonly numberOfPagesLoaded$: Observable<number>;
|
|
169
169
|
/**
|
|
170
170
|
* Whether or not there are more results to load.
|
|
171
171
|
*/
|