@dereekb/rxjs 0.0.1
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 +7 -0
- package/package.json +13 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +5 -0
- package/src/index.js.map +1 -0
- package/src/lib/index.d.ts +6 -0
- package/src/lib/index.js +10 -0
- package/src/lib/index.js.map +1 -0
- package/src/lib/iterator/index.d.ts +6 -0
- package/src/lib/iterator/index.js +10 -0
- package/src/lib/iterator/index.js.map +1 -0
- package/src/lib/iterator/iteration.accumulator.d.ts +56 -0
- package/src/lib/iterator/iteration.accumulator.js +63 -0
- package/src/lib/iterator/iteration.accumulator.js.map +1 -0
- package/src/lib/iterator/iteration.accumulator.rxjs.d.ts +14 -0
- package/src/lib/iterator/iteration.accumulator.rxjs.js +35 -0
- package/src/lib/iterator/iteration.accumulator.rxjs.js.map +1 -0
- package/src/lib/iterator/iteration.d.ts +58 -0
- package/src/lib/iterator/iteration.js +3 -0
- package/src/lib/iterator/iteration.js.map +1 -0
- package/src/lib/iterator/iteration.mapped.d.ts +38 -0
- package/src/lib/iterator/iteration.mapped.js +36 -0
- package/src/lib/iterator/iteration.mapped.js.map +1 -0
- package/src/lib/iterator/iteration.mapped.page.d.ts +25 -0
- package/src/lib/iterator/iteration.mapped.page.js +36 -0
- package/src/lib/iterator/iteration.mapped.page.js.map +1 -0
- package/src/lib/iterator/iteration.next.d.ts +27 -0
- package/src/lib/iterator/iteration.next.js +55 -0
- package/src/lib/iterator/iteration.next.js.map +1 -0
- package/src/lib/iterator/iterator.page.d.ts +172 -0
- package/src/lib/iterator/iterator.page.js +238 -0
- package/src/lib/iterator/iterator.page.js.map +1 -0
- package/src/lib/loading/index.d.ts +7 -0
- package/src/lib/loading/index.js +11 -0
- package/src/lib/loading/index.js.map +1 -0
- package/src/lib/loading/loading.context.d.ts +8 -0
- package/src/lib/loading/loading.context.js +3 -0
- package/src/lib/loading/loading.context.js.map +1 -0
- package/src/lib/loading/loading.context.simple.d.ts +17 -0
- package/src/lib/loading/loading.context.simple.js +40 -0
- package/src/lib/loading/loading.context.simple.js.map +1 -0
- package/src/lib/loading/loading.context.state.d.ts +33 -0
- package/src/lib/loading/loading.context.state.js +52 -0
- package/src/lib/loading/loading.context.state.js.map +1 -0
- package/src/lib/loading/loading.context.state.model.d.ts +18 -0
- package/src/lib/loading/loading.context.state.model.js +37 -0
- package/src/lib/loading/loading.context.state.model.js.map +1 -0
- package/src/lib/loading/loading.context.state.page.d.ts +21 -0
- package/src/lib/loading/loading.context.state.page.js +46 -0
- package/src/lib/loading/loading.context.state.page.js.map +1 -0
- package/src/lib/loading/loading.context.value.d.ts +19 -0
- package/src/lib/loading/loading.context.value.js +36 -0
- package/src/lib/loading/loading.context.value.js.map +1 -0
- package/src/lib/loading/loading.state.d.ts +90 -0
- package/src/lib/loading/loading.state.js +188 -0
- package/src/lib/loading/loading.state.js.map +1 -0
- package/src/lib/lock.d.ts +56 -0
- package/src/lib/lock.js +109 -0
- package/src/lib/lock.js.map +1 -0
- package/src/lib/object.d.ts +10 -0
- package/src/lib/object.js +25 -0
- package/src/lib/object.js.map +1 -0
- package/src/lib/rxjs/array.d.ts +32 -0
- package/src/lib/rxjs/array.js +54 -0
- package/src/lib/rxjs/array.js.map +1 -0
- package/src/lib/rxjs/boolean.d.ts +5 -0
- package/src/lib/rxjs/boolean.js +12 -0
- package/src/lib/rxjs/boolean.js.map +1 -0
- package/src/lib/rxjs/index.d.ts +6 -0
- package/src/lib/rxjs/index.js +10 -0
- package/src/lib/rxjs/index.js.map +1 -0
- package/src/lib/rxjs/loading.d.ts +5 -0
- package/src/lib/rxjs/loading.js +12 -0
- package/src/lib/rxjs/loading.js.map +1 -0
- package/src/lib/rxjs/number.d.ts +5 -0
- package/src/lib/rxjs/number.js +12 -0
- package/src/lib/rxjs/number.js.map +1 -0
- package/src/lib/rxjs/rxjs.d.ts +7 -0
- package/src/lib/rxjs/rxjs.js +32 -0
- package/src/lib/rxjs/rxjs.js.map +1 -0
- package/src/lib/rxjs/value.d.ts +18 -0
- package/src/lib/rxjs/value.js +37 -0
- package/src/lib/rxjs/value.js.map +1 -0
- package/src/lib/subscription.d.ts +28 -0
- package/src/lib/subscription.js +68 -0
- package/src/lib/subscription.js.map +1 -0
package/README.md
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dereekb/rxjs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "./src/index.js",
|
|
5
|
+
"typings": "./src/index.d.ts",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"rxjs": "^7.5.2",
|
|
8
|
+
"@dereekb/util": "0.0.1",
|
|
9
|
+
"extra-set": "^2.2.11",
|
|
10
|
+
"ms": "^3.0.0-canary.1"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {}
|
|
13
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/rxjs/src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsB"}
|
package/src/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./iterator"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./loading"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./lock"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./object"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./rxjs"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./subscription"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/rxjs/src/lib/index.ts"],"names":[],"mappings":";;;AAAA,0DAA2B;AAC3B,yDAA0B;AAC1B,sDAAuB;AACvB,wDAAyB;AACzB,sDAAuB;AACvB,8DAA+B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./iteration.next"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./iteration.accumulator.rxjs"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./iteration"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./iteration.mapped"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./iteration.mapped.page"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./iterator.page"), exports);
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/index.ts"],"names":[],"mappings":";;;AAAA,gEAAiC;AACjC,4EAA6C;AAC7C,2DAA4B;AAC5B,kEAAmC;AACnC,uEAAwC;AACxC,+DAAgC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Destroyable, Maybe } from "@dereekb/util";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { ItemIteration, PageItemIteration } from "./iteration";
|
|
4
|
+
import { LoadingState } from '../loading';
|
|
5
|
+
/**
|
|
6
|
+
* An object that accumulates and exposes values from an ItemIteration.
|
|
7
|
+
*/
|
|
8
|
+
export interface ItemAccumulator<O, I = any, N extends ItemIteration<I> = ItemIteration<I>> {
|
|
9
|
+
/**
|
|
10
|
+
* Iteration being accumulated.
|
|
11
|
+
*/
|
|
12
|
+
readonly itemIteration: N;
|
|
13
|
+
/**
|
|
14
|
+
* Returns all items loaded so far in the iteration in a single array.
|
|
15
|
+
*/
|
|
16
|
+
readonly allItems$: Observable<O[]>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* An object that accumulates and exposes values from a PageItemIteration.
|
|
20
|
+
*/
|
|
21
|
+
export declare type PageItemAccumulator<O, I = any, N extends PageItemIteration<I> = PageItemIteration<I>> = ItemAccumulator<O, I, N>;
|
|
22
|
+
/**
|
|
23
|
+
* An accumulator with no mapping.
|
|
24
|
+
*/
|
|
25
|
+
export declare type MonotypeItemAccumulator<I, N extends ItemIteration<I> = ItemIteration<I>> = ItemAccumulator<I, I, N>;
|
|
26
|
+
/**
|
|
27
|
+
* A page accumulator with no mapping.
|
|
28
|
+
*/
|
|
29
|
+
export declare type MonotypePageItemAccumulator<I, N extends PageItemIteration<I> = PageItemIteration<I>> = ItemAccumulator<I, I, N>;
|
|
30
|
+
export declare type ItemAccumulatorMapFunction<O, I> = ((item: I) => Maybe<O>) | ((item: I, state: LoadingState<I>) => Maybe<O>);
|
|
31
|
+
/**
|
|
32
|
+
* ItemAccumulator implementation.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ItemAccumulatorInstance<O, I = any, N extends ItemIteration<I> = ItemIteration<I>> implements ItemAccumulator<O, I, N>, Destroyable {
|
|
35
|
+
readonly itemIteration: N;
|
|
36
|
+
readonly mapItemFunction: ItemAccumulatorMapFunction<O, I>;
|
|
37
|
+
constructor(itemIteration: N, mapItemFunction: ItemAccumulatorMapFunction<O, I>);
|
|
38
|
+
readonly latestSuccessfulState$: Observable<LoadingState<I>>;
|
|
39
|
+
/**
|
|
40
|
+
* All successful page results in a single array.
|
|
41
|
+
*/
|
|
42
|
+
readonly allSuccessfulStates$: Observable<LoadingState<I>[]>;
|
|
43
|
+
readonly successfulLoadCount$: Observable<number>;
|
|
44
|
+
readonly allItems$: Observable<O[]>;
|
|
45
|
+
private _sub;
|
|
46
|
+
destroy(): void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new ItemAccumulator instance give the input ItemIteration.
|
|
50
|
+
*
|
|
51
|
+
* @param itemIteration
|
|
52
|
+
* @param mapItem
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare function itemAccumulator<I, N extends ItemIteration<I>>(itemIteration: N): ItemAccumulatorInstance<I, I, N>;
|
|
56
|
+
export declare function itemAccumulator<O, I, N extends ItemIteration<I>>(itemIteration: N, mapItem?: ItemAccumulatorMapFunction<O, I>): ItemAccumulatorInstance<O, I, N>;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.itemAccumulator = exports.ItemAccumulatorInstance = void 0;
|
|
4
|
+
const subscription_1 = require("../subscription");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const rxjs_1 = require("../rxjs");
|
|
7
|
+
const util_1 = require("@dereekb/util");
|
|
8
|
+
const rxjs_2 = require("rxjs");
|
|
9
|
+
const loading_1 = require("../loading");
|
|
10
|
+
/**
|
|
11
|
+
* ItemAccumulator implementation.
|
|
12
|
+
*/
|
|
13
|
+
class ItemAccumulatorInstance {
|
|
14
|
+
constructor(itemIteration, mapItemFunction) {
|
|
15
|
+
this.itemIteration = itemIteration;
|
|
16
|
+
this.mapItemFunction = mapItemFunction;
|
|
17
|
+
this.latestSuccessfulState$ = this.itemIteration.latestState$.pipe((0, operators_1.filter)(x => !(0, loading_1.loadingStateHasError)(x)), (0, operators_1.distinctUntilChanged)(), (0, rxjs_2.shareReplay)(1));
|
|
18
|
+
/**
|
|
19
|
+
* All successful page results in a single array.
|
|
20
|
+
*/
|
|
21
|
+
this.allSuccessfulStates$ = this.latestSuccessfulState$.pipe((0, rxjs_1.scanIntoArray)({ immutable: false }), (0, rxjs_1.distinctUntilArrayLengthChanges)(), (0, rxjs_2.shareReplay)(1));
|
|
22
|
+
this.successfulLoadCount$ = this.allSuccessfulStates$.pipe((0, rxjs_2.map)(x => x.length), (0, rxjs_2.shareReplay)(1));
|
|
23
|
+
// MARK: ItemAccumulator
|
|
24
|
+
this.allItems$ = this.allSuccessfulStates$.pipe((0, rxjs_1.scanBuildArray)((allSuccessfulStates) => {
|
|
25
|
+
const mapStateToItem = (state) => {
|
|
26
|
+
let result;
|
|
27
|
+
if (state.model != null) {
|
|
28
|
+
result = this.mapItemFunction(state.model, state);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
/*
|
|
33
|
+
We start with allSuccessfulPageResults$ since it contains all page results since the start of the iterator,
|
|
34
|
+
and subscription to allItems may not have started at the same time.
|
|
35
|
+
|
|
36
|
+
We use scan to add in all models coming in afterwards by pushing them into the accumulator.
|
|
37
|
+
This is to prevent performance issues with very large iteration sets, since we can
|
|
38
|
+
append onto the array, rather than concat/copy the array each time.
|
|
39
|
+
*/
|
|
40
|
+
const allPageResultsUpToFirstSubscription = allSuccessfulStates;
|
|
41
|
+
const firstLatestState = (0, util_1.lastValue)(allPageResultsUpToFirstSubscription);
|
|
42
|
+
const seed = (0, util_1.filterMaybeValues)(allPageResultsUpToFirstSubscription.map(mapStateToItem));
|
|
43
|
+
const accumulatorObs = this.latestSuccessfulState$.pipe((0, rxjs_2.skipWhile)(x => x === firstLatestState), (0, rxjs_2.map)(mapStateToItem), (0, rxjs_1.filterMaybe)());
|
|
44
|
+
return {
|
|
45
|
+
seed,
|
|
46
|
+
accumulatorObs
|
|
47
|
+
};
|
|
48
|
+
}));
|
|
49
|
+
this._sub = new subscription_1.SubscriptionObject(this.allSuccessfulStates$.subscribe());
|
|
50
|
+
}
|
|
51
|
+
destroy() {
|
|
52
|
+
this._sub.destroy();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ItemAccumulatorInstance = ItemAccumulatorInstance;
|
|
56
|
+
function itemAccumulator(itemIteration, mapItemFunction) {
|
|
57
|
+
if (!mapItemFunction) {
|
|
58
|
+
mapItemFunction = (a) => a;
|
|
59
|
+
}
|
|
60
|
+
return new ItemAccumulatorInstance(itemIteration, mapItemFunction);
|
|
61
|
+
}
|
|
62
|
+
exports.itemAccumulator = itemAccumulator;
|
|
63
|
+
//# sourceMappingURL=iteration.accumulator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.accumulator.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.accumulator.ts"],"names":[],"mappings":";;;AAAA,kDAAqD;AACrD,8CAA8D;AAC9D,kCAAsG;AACtG,wCAAiF;AACjF,+BAA+D;AAE/D,wCAAgE;AAqChE;;GAEG;AACH,MAAa,uBAAuB;IAElC,YAAqB,aAAgB,EAAW,eAAiD;QAA5E,kBAAa,GAAb,aAAa,CAAG;QAAW,oBAAe,GAAf,eAAe,CAAkC;QAExF,2BAAsB,GAAgC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CACjG,IAAA,kBAAM,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAA,8BAAoB,EAAC,CAAC,CAAC,CAAC,EACrC,IAAA,gCAAoB,GAAE,EACtB,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAEF;;WAEG;QACM,yBAAoB,GAAkC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAC7F,IAAA,oBAAa,EAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,EACnC,IAAA,sCAA+B,GAAE,EACjC,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAEO,yBAAoB,GAAuB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAChF,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAClB,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAEF,wBAAwB;QACf,cAAS,GAAoB,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAClE,IAAA,qBAAc,EAAC,CAAC,mBAAmB,EAAE,EAAE;YACrC,MAAM,cAAc,GAAyC,CAAC,KAAK,EAAE,EAAE;gBACrE,IAAI,MAAgB,CAAC;gBAErB,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE;oBACvB,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;iBACnD;gBAED,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;YAEF;;;;;;;cAOE;YACF,MAAM,mCAAmC,GAAG,mBAAmB,CAAC;YAChE,MAAM,gBAAgB,GAAG,IAAA,gBAAS,EAAC,mCAAmC,CAAC,CAAC;YACxE,MAAM,IAAI,GAAQ,IAAA,wBAAiB,EAAC,mCAAmC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;YAE7F,MAAM,cAAc,GAAkB,IAAI,CAAC,sBAAsB,CAAC,IAAI,CACpE,IAAA,gBAAS,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,gBAAgB,CAAC,EACtC,IAAA,UAAG,EAAC,cAAc,CAAC,EACnB,IAAA,kBAAW,GAAE,CACd,CAAC;YAEF,OAAO;gBACL,IAAI;gBACJ,cAAc;aACf,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;QAEM,SAAI,GAAG,IAAI,iCAAkB,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,CAAC,CAAC;IA5DwB,CAAC;IA8DtG,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACtB,CAAC;CAEF;AApED,0DAoEC;AAWD,SAAgB,eAAe,CAAmC,aAAgB,EAAE,eAAkD;IACpI,IAAI,CAAC,eAAe,EAAE;QACpB,eAAe,GAAG,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC;KACjC;IAED,OAAO,IAAI,uBAAuB,CAAU,aAAa,EAAE,eAAe,CAAC,CAAC;AAC9E,CAAC;AAND,0CAMC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { PageListLoadingState } from '../loading';
|
|
3
|
+
import { ItemAccumulator, PageItemAccumulator } from './iteration.accumulator';
|
|
4
|
+
/**
|
|
5
|
+
* Used for ItemAccumulators that have an array of results returned per page instead of a single item.
|
|
6
|
+
*
|
|
7
|
+
* @param iteration
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function flattenIterationResultItemArray<T>(iteration: ItemAccumulator<T[]>): Observable<T[]>;
|
|
11
|
+
/**
|
|
12
|
+
* A PageListLoadingState that captures all the values that have been loaded so far, and the current loading state of currentPageResult$.
|
|
13
|
+
*/
|
|
14
|
+
export declare function iterationCurrentPageListLoadingState<V>(iteration: PageItemAccumulator<V>): Observable<PageListLoadingState<V>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.iterationCurrentPageListLoadingState = exports.flattenIterationResultItemArray = void 0;
|
|
4
|
+
const util_1 = require("@dereekb/util");
|
|
5
|
+
const rxjs_1 = require("../rxjs");
|
|
6
|
+
const rxjs_2 = require("rxjs");
|
|
7
|
+
const loading_1 = require("../loading");
|
|
8
|
+
/**
|
|
9
|
+
* Used for ItemAccumulators that have an array of results returned per page instead of a single item.
|
|
10
|
+
*
|
|
11
|
+
* @param iteration
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function flattenIterationResultItemArray(iteration) {
|
|
15
|
+
return iteration.allItems$.pipe((0, rxjs_1.scanBuildArray)((allItems) => {
|
|
16
|
+
const seed = (0, util_1.flattenArray)(allItems);
|
|
17
|
+
const latestItem = (0, util_1.lastValue)(allItems);
|
|
18
|
+
const accumulatorObs = iteration.itemIteration.latestState$.pipe((0, rxjs_2.skipWhile)(x => x.model === latestItem), (0, rxjs_2.map)(x => x.model), (0, rxjs_1.filterMaybe)());
|
|
19
|
+
return {
|
|
20
|
+
seed,
|
|
21
|
+
accumulatorObs
|
|
22
|
+
};
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
exports.flattenIterationResultItemArray = flattenIterationResultItemArray;
|
|
26
|
+
/**
|
|
27
|
+
* A PageListLoadingState that captures all the values that have been loaded so far, and the current loading state of currentPageResult$.
|
|
28
|
+
*/
|
|
29
|
+
function iterationCurrentPageListLoadingState(iteration) {
|
|
30
|
+
return (0, rxjs_2.combineLatest)([iteration.itemIteration.currentState$, iteration.allItems$]).pipe((0, rxjs_2.map)(([state, values]) => (0, loading_1.mapLoadingStateResults)(state, {
|
|
31
|
+
mapValue: () => values
|
|
32
|
+
})), (0, rxjs_2.shareReplay)(1));
|
|
33
|
+
}
|
|
34
|
+
exports.iterationCurrentPageListLoadingState = iterationCurrentPageListLoadingState;
|
|
35
|
+
//# sourceMappingURL=iteration.accumulator.rxjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.accumulator.rxjs.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.accumulator.rxjs.ts"],"names":[],"mappings":";;;AAAA,wCAAwD;AACxD,kCAAsD;AACtD,+BAA8E;AAC9E,wCAA0E;AAG1E;;;;;GAKG;AACH,SAAgB,+BAA+B,CAAI,SAA+B;IAChF,OAAO,SAAS,CAAC,SAAS,CAAC,IAAI,CAC7B,IAAA,qBAAc,EAAC,CAAC,QAAe,EAAE,EAAE;QACjC,MAAM,IAAI,GAAG,IAAA,mBAAY,EAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,IAAA,gBAAS,EAAC,QAAQ,CAAC,CAAC;QAEvC,MAAM,cAAc,GAAoB,SAAS,CAAC,aAAa,CAAC,YAAY,CAAC,IAAI,CAC/E,IAAA,gBAAS,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,EACtC,IAAA,UAAG,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,EACjB,IAAA,kBAAW,GAAE,CACd,CAAC;QAEF,OAAO;YACL,IAAI;YACJ,cAAc;SACR,CAAC;IACX,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAlBD,0EAkBC;AAED;;GAEG;AACH,SAAgB,oCAAoC,CAAI,SAAiC;IACvF,OAAO,IAAA,oBAAa,EAAC,CAAC,SAAS,CAAC,aAAa,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CACrF,IAAA,UAAG,EAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,IAAA,gCAAsB,EAAC,KAAK,EAAE;QACrD,QAAQ,EAAE,GAAG,EAAE,CAAC,MAAM;KACvB,CAA4B,CAAC,EAC9B,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AACJ,CAAC;AAPD,oFAOC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { Destroyable, PageNumber } from "@dereekb/util";
|
|
3
|
+
import { LoadingState, PageLoadingState } from '../loading';
|
|
4
|
+
export interface ItemIteratorNextRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The expected page to request.
|
|
7
|
+
*
|
|
8
|
+
* If provided, the page must equal the target page, otherwise the next is ignored.
|
|
9
|
+
*/
|
|
10
|
+
page?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Whether or not to retry loading the page.
|
|
13
|
+
*/
|
|
14
|
+
retry?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ItemIteration<V = any, L extends LoadingState<V> = LoadingState<V>> extends Destroyable {
|
|
17
|
+
readonly hasNext$: Observable<boolean>;
|
|
18
|
+
readonly canLoadMore$: Observable<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* The latest stable state that has finished loading.
|
|
21
|
+
*/
|
|
22
|
+
readonly latestState$: Observable<L>;
|
|
23
|
+
/**
|
|
24
|
+
* The "current" page state.
|
|
25
|
+
*/
|
|
26
|
+
readonly currentState$: Observable<L>;
|
|
27
|
+
/**
|
|
28
|
+
* Triggers a loading of the next page.
|
|
29
|
+
*/
|
|
30
|
+
next(request?: ItemIteratorNextRequest): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* An ItemIteration that has pages.
|
|
34
|
+
*/
|
|
35
|
+
export interface PageItemIteration<V = any, L extends PageLoadingState<V> = PageLoadingState<V>> extends ItemIteration<V, L> {
|
|
36
|
+
/**
|
|
37
|
+
* The maximum number of pages allowed to be loaded.
|
|
38
|
+
*
|
|
39
|
+
* A page of 15 means that pages 0-14 can be loaded, but not page 15.
|
|
40
|
+
*/
|
|
41
|
+
maxPageLoadLimit: PageNumber;
|
|
42
|
+
/**
|
|
43
|
+
* Attempts to loads the next page of results and returns a promise.
|
|
44
|
+
*
|
|
45
|
+
* The promise will return when the next action has completed.
|
|
46
|
+
*
|
|
47
|
+
* If the page result ends in an error, this promise will throw that error.
|
|
48
|
+
*
|
|
49
|
+
* @param request
|
|
50
|
+
*/
|
|
51
|
+
nextPage(request?: ItemIteratorNextRequest): Promise<PageNumber>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns the latest page that has been fully loaded.
|
|
54
|
+
*
|
|
55
|
+
* This page can be different than the page returned in currentPageState$.
|
|
56
|
+
*/
|
|
57
|
+
readonly latestLoadedPage$: Observable<PageNumber>;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LoadingState, MapLoadingStateResultsConfiguration, PageLoadingState } from '../loading';
|
|
2
|
+
import { Destroyable } from "@dereekb/util";
|
|
3
|
+
import { Observable } from "rxjs";
|
|
4
|
+
import { ItemIteration, ItemIteratorNextRequest } from "./iteration";
|
|
5
|
+
/**
|
|
6
|
+
* An object that maps loading states from one mapping to another.
|
|
7
|
+
*/
|
|
8
|
+
export interface MappedItemIteration<O, I = any, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>> extends ItemIteration<O, M> {
|
|
9
|
+
/**
|
|
10
|
+
* Iteration being accumulated.
|
|
11
|
+
*/
|
|
12
|
+
readonly itemIteration: N;
|
|
13
|
+
}
|
|
14
|
+
export interface MappedItemIterationInstanceMapConfig<O, I, M extends LoadingState<O> = PageLoadingState<O>, L extends LoadingState<I> = PageLoadingState<I>> extends MapLoadingStateResultsConfiguration<I, O, L, M> {
|
|
15
|
+
/**
|
|
16
|
+
* Whether or not to forward the destroy() call to the base itemIteration.
|
|
17
|
+
*/
|
|
18
|
+
forwardDestroy?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class MappedItemIterationInstance<O, I = any, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>> implements ItemIteration<O>, Destroyable {
|
|
21
|
+
readonly itemIterator: N;
|
|
22
|
+
readonly config: MappedItemIterationInstanceMapConfig<O, I, M, L>;
|
|
23
|
+
constructor(itemIterator: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>);
|
|
24
|
+
readonly hasNext$: Observable<boolean>;
|
|
25
|
+
readonly canLoadMore$: Observable<boolean>;
|
|
26
|
+
readonly latestState$: Observable<M>;
|
|
27
|
+
readonly currentState$: Observable<M>;
|
|
28
|
+
next(request?: ItemIteratorNextRequest): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
33
|
+
*
|
|
34
|
+
* @param itemIteration
|
|
35
|
+
* @param config
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export declare function mapItemIteration<O, I = any, M extends LoadingState<O> = LoadingState<O>, L extends LoadingState<I> = LoadingState<I>, N extends ItemIteration<I, L> = ItemIteration<I, L>>(itemIteration: N, config: MappedItemIterationInstanceMapConfig<O, I, M, L>): MappedItemIterationInstance<O, I, M, L, N>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapItemIteration = exports.MappedItemIterationInstance = void 0;
|
|
4
|
+
const loading_1 = require("../loading");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
class MappedItemIterationInstance {
|
|
7
|
+
constructor(itemIterator, config) {
|
|
8
|
+
this.itemIterator = itemIterator;
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.hasNext$ = this.itemIterator.hasNext$;
|
|
11
|
+
this.canLoadMore$ = this.itemIterator.canLoadMore$;
|
|
12
|
+
this.latestState$ = this.itemIterator.latestState$.pipe((0, rxjs_1.map)(state => (0, loading_1.mapLoadingStateResults)(state, this.config)), (0, rxjs_1.shareReplay)(1));
|
|
13
|
+
this.currentState$ = this.itemIterator.currentState$.pipe((0, rxjs_1.map)(state => (0, loading_1.mapLoadingStateResults)(state, this.config)), (0, rxjs_1.shareReplay)(1));
|
|
14
|
+
}
|
|
15
|
+
next(request) {
|
|
16
|
+
return this.itemIterator.next(request);
|
|
17
|
+
}
|
|
18
|
+
destroy() {
|
|
19
|
+
if (this.config.forwardDestroy !== false) {
|
|
20
|
+
this.itemIterator.destroy();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.MappedItemIterationInstance = MappedItemIterationInstance;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
27
|
+
*
|
|
28
|
+
* @param itemIteration
|
|
29
|
+
* @param config
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
function mapItemIteration(itemIteration, config) {
|
|
33
|
+
return new MappedItemIterationInstance(itemIteration, config);
|
|
34
|
+
}
|
|
35
|
+
exports.mapItemIteration = mapItemIteration;
|
|
36
|
+
//# sourceMappingURL=iteration.mapped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.mapped.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.mapped.ts"],"names":[],"mappings":";;;AAAA,wCAAyH;AAEzH,+BAAoD;AAoCpD,MAAa,2BAA2B;IAQtC,YAAqB,YAAe,EAAW,MAAwD;QAAlF,iBAAY,GAAZ,YAAY,CAAG;QAAW,WAAM,GAAN,MAAM,CAAkD;QAE9F,aAAQ,GAAwB,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC;QAC3D,iBAAY,GAAwB,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;QAEnE,iBAAY,GAAkB,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,CACxE,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE,CAAC,IAAA,gCAAsB,EAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EACxD,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;QAEO,kBAAa,GAAkB,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAC1E,IAAA,UAAG,EAAC,KAAK,CAAC,EAAE,CAAC,IAAA,gCAAsB,EAAa,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,EACpE,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;IAbyG,CAAC;IAe5G,IAAI,CAAC,OAAiC;QACpC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,KAAK,KAAK,EAAE;YACxC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;SAC7B;IACH,CAAC;CAEF;AAjCD,kEAiCC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAM9B,aAAgB,EAAE,MAAwD;IAC1E,OAAO,IAAI,2BAA2B,CAAgB,aAAa,EAAE,MAAM,CAAC,CAAC;AAC/E,CAAC;AARD,4CAQC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PageLoadingState } from '../loading';
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { ItemIteratorNextRequest, PageItemIteration } from "./iteration";
|
|
4
|
+
import { MappedItemIteration, MappedItemIterationInstance, MappedItemIterationInstanceMapConfig } from './iteration.mapped';
|
|
5
|
+
/**
|
|
6
|
+
* MappedItemIteration for PageItemIteration
|
|
7
|
+
*/
|
|
8
|
+
export declare type MappedPageItemIteration<O, I = any, M extends PageLoadingState<O> = PageLoadingState<O>, L extends PageLoadingState<I> = PageLoadingState<I>, N extends PageItemIteration<I, L> = PageItemIteration<I, L>> = MappedItemIteration<O, I, M, L, N>;
|
|
9
|
+
/**
|
|
10
|
+
* MappedItemIterationInstance extension that implements PageItemIteration.
|
|
11
|
+
*/
|
|
12
|
+
export declare class MappedPageItemIterationInstance<O, I = any, 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> implements PageItemIteration<O, M> {
|
|
13
|
+
get maxPageLoadLimit(): number;
|
|
14
|
+
set maxPageLoadLimit(maxPageLoadLimit: number);
|
|
15
|
+
readonly latestLoadedPage$: Observable<number>;
|
|
16
|
+
nextPage(request?: ItemIteratorNextRequest): Promise<number>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
20
|
+
*
|
|
21
|
+
* @param itemIteration
|
|
22
|
+
* @param config
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function mapPageItemIteration<O, I = any, 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>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapPageItemIteration = exports.MappedPageItemIterationInstance = void 0;
|
|
4
|
+
const iteration_mapped_1 = require("./iteration.mapped");
|
|
5
|
+
/**
|
|
6
|
+
* MappedItemIterationInstance extension that implements PageItemIteration.
|
|
7
|
+
*/
|
|
8
|
+
class MappedPageItemIterationInstance extends iteration_mapped_1.MappedItemIterationInstance {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.latestLoadedPage$ = this.itemIterator.latestLoadedPage$;
|
|
12
|
+
}
|
|
13
|
+
// MARK: PageItemIteration
|
|
14
|
+
get maxPageLoadLimit() {
|
|
15
|
+
return this.itemIterator.maxPageLoadLimit;
|
|
16
|
+
}
|
|
17
|
+
set maxPageLoadLimit(maxPageLoadLimit) {
|
|
18
|
+
this.itemIterator.maxPageLoadLimit = maxPageLoadLimit;
|
|
19
|
+
}
|
|
20
|
+
nextPage(request) {
|
|
21
|
+
return this.itemIterator.nextPage(request);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.MappedPageItemIterationInstance = MappedPageItemIterationInstance;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new MappedItemIteration instance given the input ItemIteration and config.
|
|
27
|
+
*
|
|
28
|
+
* @param itemIteration
|
|
29
|
+
* @param config
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
function mapPageItemIteration(itemIteration, config) {
|
|
33
|
+
return new MappedPageItemIterationInstance(itemIteration, config);
|
|
34
|
+
}
|
|
35
|
+
exports.mapPageItemIteration = mapPageItemIteration;
|
|
36
|
+
//# sourceMappingURL=iteration.mapped.page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.mapped.page.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.mapped.page.ts"],"names":[],"mappings":";;;AAGA,yDAA4H;AAc5H;;GAEG;AACH,MAAa,+BAMT,SAAQ,8CAA0C;IANtD;;QAiBW,sBAAiB,GAAuB,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC;IAMvF,CAAC;IAfC,0BAA0B;IAC1B,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC;IAC5C,CAAC;IAED,IAAI,gBAAgB,CAAC,gBAAwB;QAC3C,IAAI,CAAC,YAAY,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IACxD,CAAC;IAID,QAAQ,CAAC,OAAiC;QACxC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CAEF;AAvBD,0EAuBC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAMlC,aAAgB,EAAE,MAAwD;IAC1E,OAAO,IAAI,+BAA+B,CAAgB,aAAa,EAAE,MAAM,CAAC,CAAC;AACnF,CAAC;AARD,oDAQC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { ItemIteration, PageItemIteration } from "./iteration";
|
|
3
|
+
/**
|
|
4
|
+
* Creates an observable from the input iteration that checks both the hasNext$ and canLoadMore$ states.
|
|
5
|
+
*
|
|
6
|
+
* @param iteration
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function iterationHasNextAndCanLoadMore<V>(iteration: ItemIteration<V>): Observable<boolean>;
|
|
10
|
+
/**
|
|
11
|
+
* Automatically calls next up to the current maxPageLoadLimit.
|
|
12
|
+
*
|
|
13
|
+
* The promise will reject with an error if an error is encountered.
|
|
14
|
+
*
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
export declare function iteratorNextPageUntilMaxPageLoadLimit(iterator: PageItemIteration): Promise<number>;
|
|
18
|
+
/**
|
|
19
|
+
* Automatically calls next on the PageItemIteration up to the target page, the number of total pages that should be loaded.
|
|
20
|
+
*
|
|
21
|
+
* The promise will reject with an error if an error is encountered.
|
|
22
|
+
*
|
|
23
|
+
* @param iteration
|
|
24
|
+
* @param page
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
export declare function iteratorNextPageUntilPage(iteration: PageItemIteration, page: number | (() => number)): Promise<number>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.iteratorNextPageUntilPage = exports.iteratorNextPageUntilMaxPageLoadLimit = exports.iterationHasNextAndCanLoadMore = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
|
+
const util_1 = require("@dereekb/util");
|
|
7
|
+
/**
|
|
8
|
+
* Creates an observable from the input iteration that checks both the hasNext$ and canLoadMore$ states.
|
|
9
|
+
*
|
|
10
|
+
* @param iteration
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function iterationHasNextAndCanLoadMore(iteration) {
|
|
14
|
+
return (0, rxjs_1.combineLatest)([iteration.hasNext$, iteration.canLoadMore$]).pipe((0, rxjs_1.map)((0, util_1.reduceBooleansWithAndFn)(true)), (0, rxjs_1.shareReplay)(1));
|
|
15
|
+
}
|
|
16
|
+
exports.iterationHasNextAndCanLoadMore = iterationHasNextAndCanLoadMore;
|
|
17
|
+
/**
|
|
18
|
+
* Automatically calls next up to the current maxPageLoadLimit.
|
|
19
|
+
*
|
|
20
|
+
* The promise will reject with an error if an error is encountered.
|
|
21
|
+
*
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
function iteratorNextPageUntilMaxPageLoadLimit(iterator) {
|
|
25
|
+
return iteratorNextPageUntilPage(iterator, () => iterator.maxPageLoadLimit);
|
|
26
|
+
}
|
|
27
|
+
exports.iteratorNextPageUntilMaxPageLoadLimit = iteratorNextPageUntilMaxPageLoadLimit;
|
|
28
|
+
/**
|
|
29
|
+
* Automatically calls next on the PageItemIteration up to the target page, the number of total pages that should be loaded.
|
|
30
|
+
*
|
|
31
|
+
* The promise will reject with an error if an error is encountered.
|
|
32
|
+
*
|
|
33
|
+
* @param iteration
|
|
34
|
+
* @param page
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
function iteratorNextPageUntilPage(iteration, page) {
|
|
38
|
+
const getPageLimit = (typeof page === 'function') ? page : () => page;
|
|
39
|
+
function checkPageLimit(page) {
|
|
40
|
+
const pageLimit = getPageLimit();
|
|
41
|
+
return (page + 1) < Math.min(pageLimit, iteration.maxPageLoadLimit);
|
|
42
|
+
}
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
iteration.latestLoadedPage$.pipe((0, rxjs_1.first)()).subscribe((firstLatestPage) => {
|
|
45
|
+
const promise = (0, util_1.performTaskLoop)({
|
|
46
|
+
initValue: firstLatestPage,
|
|
47
|
+
checkContinue: (latestPage) => checkPageLimit(latestPage),
|
|
48
|
+
next: () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return yield iteration.nextPage(); })
|
|
49
|
+
});
|
|
50
|
+
resolve(promise);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.iteratorNextPageUntilPage = iteratorNextPageUntilPage;
|
|
55
|
+
//# sourceMappingURL=iteration.next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iteration.next.js","sourceRoot":"","sources":["../../../../../../packages/rxjs/src/lib/iterator/iteration.next.ts"],"names":[],"mappings":";;;;AAAA,+BAA0E;AAE1E,wCAAyE;AAEzE;;;;;GAKG;AACH,SAAgB,8BAA8B,CAAI,SAA2B;IAC3E,OAAO,IAAA,oBAAa,EAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CACrE,IAAA,UAAG,EAAC,IAAA,8BAAuB,EAAC,IAAI,CAAC,CAAC,EAClC,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AACJ,CAAC;AALD,wEAKC;AAED;;;;;;GAMG;AACH,SAAgB,qCAAqC,CAAC,QAA2B;IAC/E,OAAO,yBAAyB,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC9E,CAAC;AAFD,sFAEC;AAED;;;;;;;;GAQG;AACH,SAAgB,yBAAyB,CAAC,SAA4B,EAAE,IAA6B;IACnG,MAAM,YAAY,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;IAEtE,SAAS,cAAc,CAAC,IAAY;QAClC,MAAM,SAAS,GAAG,YAAY,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAC9B,IAAA,YAAK,GAAE,CACR,CAAC,SAAS,CAAC,CAAC,eAAuB,EAAE,EAAE;YACtC,MAAM,OAAO,GAAoB,IAAA,sBAAe,EAAS;gBACvD,SAAS,EAAE,eAAe;gBAC1B,aAAa,EAAE,CAAC,UAAkB,EAAE,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC;gBACjE,IAAI,EAAE,GAAS,EAAE,6DAAC,OAAA,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAA,GAAA;aAC7C,CAAC,CAAC;YAEH,OAAO,CAAC,OAAO,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AArBD,8DAqBC"}
|