@ringcentral/juno 2.40.1 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Downshift/SuggestionList/SuggestionList.d.ts +3 -3
- package/components/Downshift/utils/useDownshift.d.ts +1 -1
- package/components/Virtuoso/index.d.ts +1 -1
- package/components/Virtuoso/index.js +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.d.ts +5 -0
- package/components/Virtuoso/react-virtuoso/TableVirtuoso.js +217 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.d.ts +7696 -0
- package/components/Virtuoso/react-virtuoso/Virtuoso.js +317 -0
- package/components/Virtuoso/react-virtuoso/{Grid.d.ts → VirtuosoGrid.d.ts} +170 -72
- package/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +199 -0
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.d.ts +119 -65
- package/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/components/Virtuoso/react-virtuoso/comparators.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.d.ts +194 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.d.ts +274 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +2 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.d.ts +125 -0
- package/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +2 -0
- package/components/Virtuoso/react-virtuoso/domIOSystem.d.ts +3 -2
- package/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/components/Virtuoso/react-virtuoso/followOutputSystem.d.ts +80 -43
- package/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/components/Virtuoso/react-virtuoso/gridSystem.d.ts +57 -31
- package/components/Virtuoso/react-virtuoso/gridSystem.js +173 -86
- package/components/Virtuoso/react-virtuoso/groupedListSystem.d.ts +76 -67
- package/components/Virtuoso/react-virtuoso/groupedListSystem.js +12 -12
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.d.ts +6 -3
- package/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +36 -17
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.d.ts +2 -2
- package/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +3 -2
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.d.ts +2 -0
- package/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +5 -0
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +36 -51
- package/components/Virtuoso/react-virtuoso/hooks/useSize.d.ts +2 -3
- package/components/Virtuoso/react-virtuoso/hooks/useSize.js +13 -13
- package/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +17 -15
- package/components/Virtuoso/react-virtuoso/index.d.ts +7 -1
- package/components/Virtuoso/react-virtuoso/index.js +8 -1
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.d.ts +304 -68
- package/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +9 -31
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.d.ts +127 -109
- package/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.d.ts +38 -22
- package/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/components/Virtuoso/react-virtuoso/interfaces.d.ts +150 -51
- package/components/Virtuoso/react-virtuoso/listStateSystem.d.ts +109 -59
- package/components/Virtuoso/react-virtuoso/listStateSystem.js +100 -52
- package/components/Virtuoso/react-virtuoso/listSystem.d.ts +1691 -693
- package/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/components/Virtuoso/react-virtuoso/loggerSystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/components/Virtuoso/react-virtuoso/propsReadySystem.d.ts +1 -1
- package/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/components/Virtuoso/react-virtuoso/react-urx/index.d.ts +110 -0
- package/components/Virtuoso/react-virtuoso/react-urx/index.js +200 -0
- package/components/Virtuoso/react-virtuoso/react-urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.d.ts +4 -0
- package/components/Virtuoso/react-virtuoso/recalcSystem.js +8 -0
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.d.ts +144 -78
- package/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +33 -21
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.d.ts +12 -7
- package/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.d.ts +19 -11
- package/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.d.ts +7 -6
- package/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +15 -27
- package/components/Virtuoso/react-virtuoso/sizeSystem.d.ts +20 -11
- package/components/Virtuoso/react-virtuoso/sizeSystem.js +182 -52
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.d.ts +8 -5
- package/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.d.ts +318 -0
- package/components/Virtuoso/react-virtuoso/stateLoadSystem.js +41 -0
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.d.ts +518 -467
- package/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.d.ts +115 -63
- package/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.d.ts +139 -73
- package/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +74 -31
- package/components/Virtuoso/react-virtuoso/urx/actions.d.ts +127 -0
- package/components/Virtuoso/react-virtuoso/urx/actions.js +98 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.d.ts +8 -0
- package/components/Virtuoso/react-virtuoso/urx/constants.js +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.d.ts +6 -0
- package/components/Virtuoso/react-virtuoso/urx/index.js +9 -0
- package/components/Virtuoso/react-virtuoso/urx/package.json +5 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.d.ts +220 -0
- package/components/Virtuoso/react-virtuoso/urx/pipe.js +279 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.d.ts +143 -0
- package/components/Virtuoso/react-virtuoso/urx/streams.js +227 -0
- package/components/Virtuoso/react-virtuoso/urx/system.d.ts +148 -0
- package/components/Virtuoso/react-virtuoso/urx/system.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.d.ts +71 -0
- package/components/Virtuoso/react-virtuoso/urx/transformers.js +106 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.d.ts +57 -0
- package/components/Virtuoso/react-virtuoso/urx/utils.js +102 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/context.d.ts +13 -0
- package/components/Virtuoso/react-virtuoso/utils/context.js +6 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.d.ts +1 -0
- package/components/Virtuoso/react-virtuoso/utils/skipFrames.js +11 -0
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.d.ts +6 -4
- package/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/components/Virtuoso/utils/isOutOfRange.d.ts +1 -1
- package/components/Virtuoso/utils/useHighlightScroll.d.ts +2 -2
- package/es6/components/Virtuoso/index.js +1 -1
- package/es6/components/Virtuoso/react-virtuoso/AATree.js +60 -48
- package/es6/components/Virtuoso/react-virtuoso/{Table.js → TableVirtuoso.js} +73 -52
- package/es6/components/Virtuoso/react-virtuoso/{List.js → Virtuoso.js} +85 -161
- package/es6/components/Virtuoso/react-virtuoso/VirtuosoGrid.js +198 -0
- package/es6/components/Virtuoso/react-virtuoso/alignToBottomSystem.js +3 -3
- package/es6/components/Virtuoso/react-virtuoso/comparators.js +1 -3
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/TableVirtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/Virtuoso.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/component-interfaces/VirtuosoGrid.js +0 -0
- package/es6/components/Virtuoso/react-virtuoso/domIOSystem.js +5 -3
- package/es6/components/Virtuoso/react-virtuoso/followOutputSystem.js +21 -19
- package/es6/components/Virtuoso/react-virtuoso/gridSystem.js +173 -87
- package/es6/components/Virtuoso/react-virtuoso/groupedListSystem.js +13 -13
- package/es6/components/Virtuoso/react-virtuoso/hooks/useChangedChildSizes.js +35 -16
- package/es6/components/Virtuoso/react-virtuoso/hooks/useIsomorphicLayoutEffect.js +2 -2
- package/es6/components/Virtuoso/react-virtuoso/hooks/useRcPortalWindowContext.js +2 -0
- package/es6/components/Virtuoso/react-virtuoso/hooks/useScrollTop.js +35 -50
- package/es6/components/Virtuoso/react-virtuoso/hooks/useSize.js +11 -12
- package/es6/components/Virtuoso/react-virtuoso/hooks/useWindowViewportRect.js +15 -14
- package/es6/components/Virtuoso/react-virtuoso/index.js +4 -1
- package/es6/components/Virtuoso/react-virtuoso/initialItemCountSystem.js +11 -33
- package/es6/components/Virtuoso/react-virtuoso/initialScrollTopSystem.js +7 -7
- package/es6/components/Virtuoso/react-virtuoso/initialTopMostItemIndexSystem.js +13 -20
- package/es6/components/Virtuoso/react-virtuoso/listStateSystem.js +101 -54
- package/es6/components/Virtuoso/react-virtuoso/listSystem.js +15 -16
- package/es6/components/Virtuoso/react-virtuoso/loggerSystem.js +2 -4
- package/es6/components/Virtuoso/react-virtuoso/propsReadySystem.js +3 -4
- package/es6/components/Virtuoso/react-virtuoso/react-urx/index.js +197 -0
- package/es6/components/Virtuoso/react-virtuoso/recalcSystem.js +5 -0
- package/es6/components/Virtuoso/react-virtuoso/scrollIntoViewSystem.js +34 -22
- package/es6/components/Virtuoso/react-virtuoso/scrollSeekSystem.js +7 -10
- package/es6/components/Virtuoso/react-virtuoso/scrollToIndexSystem.js +11 -23
- package/es6/components/Virtuoso/react-virtuoso/sizeRangeSystem.js +16 -28
- package/es6/components/Virtuoso/react-virtuoso/sizeSystem.js +180 -53
- package/es6/components/Virtuoso/react-virtuoso/stateFlagsSystem.js +32 -23
- package/es6/components/Virtuoso/react-virtuoso/stateLoadSystem.js +39 -0
- package/es6/components/Virtuoso/react-virtuoso/topItemCountSystem.js +5 -5
- package/es6/components/Virtuoso/react-virtuoso/totalListHeightSystem.js +6 -13
- package/es6/components/Virtuoso/react-virtuoso/upwardScrollFixSystem.js +75 -32
- package/es6/components/Virtuoso/react-virtuoso/urx/actions.js +90 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/constants.js +4 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/index.js +6 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/pipe.js +266 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/streams.js +220 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/system.js +102 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/transformers.js +101 -0
- package/es6/components/Virtuoso/react-virtuoso/urx/utils.js +88 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/approximatelyEqual.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/context.js +3 -0
- package/es6/components/Virtuoso/react-virtuoso/utils/skipFrames.js +8 -0
- package/es6/components/Virtuoso/react-virtuoso/windowScrollerSystem.js +1 -1
- package/package.json +2 -2
- package/components/Virtuoso/Virtuoso.d.ts +0 -1
- package/components/Virtuoso/Virtuoso.js +0 -4
- package/components/Virtuoso/react-virtuoso/Grid.js +0 -168
- package/components/Virtuoso/react-virtuoso/List.d.ts +0 -6749
- package/components/Virtuoso/react-virtuoso/List.js +0 -393
- package/components/Virtuoso/react-virtuoso/Table.d.ts +0 -6515
- package/components/Virtuoso/react-virtuoso/Table.js +0 -196
- package/components/Virtuoso/react-virtuoso/components.d.ts +0 -505
- package/components/Virtuoso/react-virtuoso/components.js +0 -9
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.d.ts +0 -1
- package/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -11
- package/es6/components/Virtuoso/Virtuoso.js +0 -1
- package/es6/components/Virtuoso/react-virtuoso/Grid.js +0 -166
- package/es6/components/Virtuoso/react-virtuoso/components.js +0 -7
- package/es6/components/Virtuoso/react-virtuoso/utils/conditionalFlushSync.js +0 -8
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var u = tslib_1.__importStar(require("
|
|
4
|
+
var u = tslib_1.__importStar(require("./urx"));
|
|
5
5
|
var domIOSystem_1 = require("./domIOSystem");
|
|
6
6
|
var listStateSystem_1 = require("./listStateSystem");
|
|
7
|
-
var loggerSystem_1 = require("./loggerSystem");
|
|
8
7
|
var sizeSystem_1 = require("./sizeSystem");
|
|
9
8
|
var stateFlagsSystem_1 = require("./stateFlagsSystem");
|
|
9
|
+
var loggerSystem_1 = require("./loggerSystem");
|
|
10
|
+
var simpleMemoize_1 = require("./utils/simpleMemoize");
|
|
11
|
+
var recalcSystem_1 = require("./recalcSystem");
|
|
12
|
+
var AATree_1 = require("./AATree");
|
|
13
|
+
var isMobileSafari = simpleMemoize_1.simpleMemoize(function () {
|
|
14
|
+
return /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.test(navigator.userAgent);
|
|
15
|
+
});
|
|
10
16
|
/**
|
|
11
17
|
* Fixes upward scrolling by calculating and compensation from changed item heights, using scrollBy.
|
|
12
18
|
*/
|
|
13
19
|
exports.upwardScrollFixSystem = u.system(function (_a) {
|
|
14
|
-
var _b = tslib_1.__read(_a,
|
|
20
|
+
var _b = tslib_1.__read(_a, 6), _c = _b[0], scrollBy = _c.scrollBy, scrollTop = _c.scrollTop, deviation = _c.deviation, scrollingInProgress = _c.scrollingInProgress, _d = _b[1], isScrolling = _d.isScrolling, isAtBottom = _d.isAtBottom, scrollDirection = _d.scrollDirection, lastJumpDueToItemResize = _d.lastJumpDueToItemResize, listState = _b[2].listState, _e = _b[3], beforeUnshiftWith = _e.beforeUnshiftWith, shiftWithOffset = _e.shiftWithOffset, sizes = _e.sizes, gap = _e.gap, log = _b[4].log, recalcInProgress = _b[5].recalcInProgress;
|
|
15
21
|
var deviationOffset = u.streamFromEmitter(u.pipe(listState, u.withLatestFrom(lastJumpDueToItemResize), u.scan(function (_a, _b) {
|
|
16
22
|
var _c = tslib_1.__read(_a, 4), prevItems = _c[1], prevTotalCount = _c[2], prevTotalHeight = _c[3];
|
|
17
|
-
var _d = tslib_1.__read(_b, 2),
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
_e = _d[0], items = _e.items, totalCount = _e.totalCount, bottom = _e.bottom, offsetBottom = _e.offsetBottom, lastJumpDueToItemResize = _d[1];
|
|
23
|
+
var _d = tslib_1.__read(_b, 2), _e = _d[0], items = _e.items, totalCount = _e.totalCount, bottom = _e.bottom, offsetBottom = _e.offsetBottom, lastJumpDueToItemResize = _d[1];
|
|
20
24
|
var totalHeight = bottom + offsetBottom;
|
|
21
25
|
var newDev = 0;
|
|
22
26
|
if (prevTotalCount === totalCount) {
|
|
23
27
|
if (prevItems.length > 0 && items.length > 0) {
|
|
24
|
-
var atStart = items[0].originalIndex === 0 &&
|
|
25
|
-
prevItems[0].originalIndex === 0;
|
|
28
|
+
var atStart = items[0].originalIndex === 0 && prevItems[0].originalIndex === 0;
|
|
26
29
|
if (!atStart) {
|
|
27
30
|
newDev = totalHeight - prevTotalHeight;
|
|
28
31
|
if (newDev !== 0) {
|
|
@@ -35,28 +38,15 @@ exports.upwardScrollFixSystem = u.system(function (_a) {
|
|
|
35
38
|
}, [0, [], 0, 0]), u.filter(function (_a) {
|
|
36
39
|
var _b = tslib_1.__read(_a, 1), amount = _b[0];
|
|
37
40
|
return amount !== 0;
|
|
38
|
-
}), u.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress,
|
|
39
|
-
var _b = tslib_1.__read(_a,
|
|
40
|
-
|
|
41
|
-
return (!scrollingInProgress && scrollTop !== 0 && scrollDirection === stateFlagsSystem_1.UP); // && (isAtBottom ? amount > 0 : true)
|
|
41
|
+
}), u.withLatestFrom(scrollTop, scrollDirection, scrollingInProgress, isAtBottom, log, recalcInProgress), u.filter(function (_a) {
|
|
42
|
+
var _b = tslib_1.__read(_a, 7), scrollTop = _b[1], scrollDirection = _b[2], scrollingInProgress = _b[3], recalcInProgress = _b[6];
|
|
43
|
+
return !recalcInProgress && !scrollingInProgress && scrollTop !== 0 && scrollDirection === stateFlagsSystem_1.UP;
|
|
42
44
|
}), u.map(function (_a) {
|
|
43
|
-
var _b = tslib_1.__read(_a,
|
|
45
|
+
var _b = tslib_1.__read(_a, 6), _c = tslib_1.__read(_b[0], 1), amount = _c[0], log = _b[5];
|
|
44
46
|
log('Upward scrolling compensation', { amount: amount }, loggerSystem_1.LogLevel.DEBUG);
|
|
45
47
|
return amount;
|
|
46
48
|
})));
|
|
47
|
-
|
|
48
|
-
var _b = tslib_1.__read(_a, 2), amount = _b[0], deviation = _b[1];
|
|
49
|
-
return deviation - amount;
|
|
50
|
-
})), deviation);
|
|
51
|
-
// when the browser stops scrolling,
|
|
52
|
-
// restore the position and reset the glitching
|
|
53
|
-
u.subscribe(u.pipe(u.combineLatest(u.statefulStreamFromEmitter(isScrolling, false), deviation), u.filter(function (_a) {
|
|
54
|
-
var _b = tslib_1.__read(_a, 2), is = _b[0], deviation = _b[1];
|
|
55
|
-
return !is && deviation !== 0;
|
|
56
|
-
}), u.map(function (_a) {
|
|
57
|
-
var _b = tslib_1.__read(_a, 2), deviation = _b[1];
|
|
58
|
-
return deviation;
|
|
59
|
-
}), u.throttleTime(1)), function (offset) {
|
|
49
|
+
function scrollByWith(offset) {
|
|
60
50
|
if (offset > 0) {
|
|
61
51
|
u.publish(scrollBy, { top: -offset, behavior: 'auto' });
|
|
62
52
|
u.publish(deviation, 0);
|
|
@@ -65,13 +55,66 @@ exports.upwardScrollFixSystem = u.system(function (_a) {
|
|
|
65
55
|
u.publish(deviation, 0);
|
|
66
56
|
u.publish(scrollBy, { top: -offset, behavior: 'auto' });
|
|
67
57
|
}
|
|
58
|
+
}
|
|
59
|
+
u.subscribe(u.pipe(deviationOffset, u.withLatestFrom(deviation, isScrolling)), function (_a) {
|
|
60
|
+
var _b = tslib_1.__read(_a, 3), offset = _b[0], deviationAmount = _b[1], isScrolling = _b[2];
|
|
61
|
+
if (isScrolling && isMobileSafari()) {
|
|
62
|
+
u.publish(deviation, deviationAmount - offset);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
scrollByWith(-offset);
|
|
66
|
+
}
|
|
68
67
|
});
|
|
68
|
+
// this hack is only necessary for mobile safari which does not support scrollBy while scrolling is in progress.
|
|
69
|
+
// when the browser stops scrolling, restore the position and reset the glitching
|
|
70
|
+
u.subscribe(u.pipe(u.combineLatest(u.statefulStreamFromEmitter(isScrolling, false), deviation, recalcInProgress), u.filter(function (_a) {
|
|
71
|
+
var _b = tslib_1.__read(_a, 3), is = _b[0], deviation = _b[1], recalc = _b[2];
|
|
72
|
+
return !is && !recalc && deviation !== 0;
|
|
73
|
+
}), u.map(function (_a) {
|
|
74
|
+
var _b = tslib_1.__read(_a, 2), _ = _b[0], deviation = _b[1];
|
|
75
|
+
return deviation;
|
|
76
|
+
}), u.throttleTime(1)), scrollByWith);
|
|
69
77
|
u.connect(u.pipe(shiftWithOffset, u.map(function (offset) {
|
|
70
78
|
return { top: -offset };
|
|
71
79
|
})), scrollBy);
|
|
72
|
-
u.
|
|
73
|
-
var _b = tslib_1.__read(_a,
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
u.subscribe(u.pipe(beforeUnshiftWith, u.withLatestFrom(sizes, gap), u.map(function (_a) {
|
|
81
|
+
var _b = tslib_1.__read(_a, 3), offset = _b[0], _c = _b[1], defaultItemSize = _c.lastSize, groupIndices = _c.groupIndices, sizeTree = _c.sizeTree, gap = _b[2];
|
|
82
|
+
function getItemOffset(itemCount) {
|
|
83
|
+
return itemCount * (defaultItemSize + gap);
|
|
84
|
+
}
|
|
85
|
+
if (groupIndices.length === 0) {
|
|
86
|
+
return getItemOffset(offset);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
var amount = 0;
|
|
90
|
+
var defaultGroupSize = AATree_1.find(sizeTree, 0);
|
|
91
|
+
var recognizedOffsetItems = 0;
|
|
92
|
+
var groupIndex = 0;
|
|
93
|
+
while (recognizedOffsetItems < offset) {
|
|
94
|
+
// increase once for the group itself
|
|
95
|
+
recognizedOffsetItems++;
|
|
96
|
+
amount += defaultGroupSize;
|
|
97
|
+
var groupItemCount = groupIndices.length === groupIndex + 1 ? Infinity : groupIndices[groupIndex + 1] - groupIndices[groupIndex] - 1;
|
|
98
|
+
// if the group is larger than the offset, we have an expanded group. remove the group size, and replace with 1 item.
|
|
99
|
+
if (recognizedOffsetItems + groupItemCount > offset) {
|
|
100
|
+
amount -= defaultGroupSize;
|
|
101
|
+
groupItemCount = offset - recognizedOffsetItems + 1;
|
|
102
|
+
}
|
|
103
|
+
recognizedOffsetItems += groupItemCount;
|
|
104
|
+
amount += getItemOffset(groupItemCount);
|
|
105
|
+
groupIndex++;
|
|
106
|
+
}
|
|
107
|
+
return amount;
|
|
108
|
+
}
|
|
109
|
+
})), function (offset) {
|
|
110
|
+
u.publish(deviation, offset);
|
|
111
|
+
requestAnimationFrame(function () {
|
|
112
|
+
u.publish(scrollBy, { top: offset });
|
|
113
|
+
requestAnimationFrame(function () {
|
|
114
|
+
u.publish(deviation, 0);
|
|
115
|
+
u.publish(recalcInProgress, false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
76
119
|
return { deviation: deviation };
|
|
77
|
-
}, u.tup(domIOSystem_1.domIOSystem, stateFlagsSystem_1.stateFlagsSystem, listStateSystem_1.listStateSystem, sizeSystem_1.sizeSystem, loggerSystem_1.loggerSystem));
|
|
120
|
+
}, u.tup(domIOSystem_1.domIOSystem, stateFlagsSystem_1.stateFlagsSystem, listStateSystem_1.listStateSystem, sizeSystem_1.sizeSystem, loggerSystem_1.loggerSystem, recalcSystem_1.recalcSystem));
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* urx Actions operate on streams - `publish` publishes data in a stream, and `subscribe` attaches a subscription to a stream.
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { PUBLISH, RESET, SUBSCRIBE, VALUE } from './constants';
|
|
6
|
+
/**
|
|
7
|
+
* A Publisher is the **input end** of a Stream. The [[publish]] action publishes values in publishers.
|
|
8
|
+
* @typeParam T the type of values to be published.
|
|
9
|
+
*/
|
|
10
|
+
export interface Publisher<T> {
|
|
11
|
+
/** @internal */
|
|
12
|
+
(action: PUBLISH, value: T): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* An Emitter is the **output end** of a Stream. The [[subscribe]] action binds {@link Subscription | subscriptions} to emitters.
|
|
16
|
+
* @typeParam T the type of values that will be emitted.
|
|
17
|
+
*/
|
|
18
|
+
export interface Emitter<T> {
|
|
19
|
+
/** @internal */
|
|
20
|
+
(action: SUBSCRIBE, subscription: Subscription<T>): Unsubscribe;
|
|
21
|
+
/** @internal */
|
|
22
|
+
(action: RESET): void;
|
|
23
|
+
}
|
|
24
|
+
export interface Cell<T> {
|
|
25
|
+
/** @internal */
|
|
26
|
+
(action: VALUE): T;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Subscriptions are bound to Emitters with the [[subscribe]] action, and get called with the new values.
|
|
30
|
+
* @typeParam T the Emitter value type.
|
|
31
|
+
*/
|
|
32
|
+
export interface Subscription<T> {
|
|
33
|
+
(value: T): any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Subscribe-like actions return unsubscribe handles of the Unsubscribe type, which, when called, unbind the subscription.
|
|
37
|
+
*/
|
|
38
|
+
export interface Unsubscribe {
|
|
39
|
+
(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare type StreamArgs<T> = [PUBLISH] | [SUBSCRIBE, Subscription<T>] | [RESET];
|
|
42
|
+
/**
|
|
43
|
+
* Streams present both the input and the output ends of a stream.
|
|
44
|
+
* A single stream instance can be both subscribed to and published in.
|
|
45
|
+
*/
|
|
46
|
+
export interface Stream<T> extends Publisher<T>, Emitter<T> {
|
|
47
|
+
/** @internal */
|
|
48
|
+
(action: SUBSCRIBE | PUBLISH | RESET): any;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Just like {@link Stream | streams}, stateful streams present both input and output ends of a stream.
|
|
52
|
+
* A single stream instance can be both subscribed to and published in.
|
|
53
|
+
* Stateful Streams can also act like depots, preserving the last passed value and immediately publishing it to new subscriptions.
|
|
54
|
+
* [[getValue]] can be used to extract value from stateful streams.
|
|
55
|
+
*/
|
|
56
|
+
export interface StatefulStream<T> extends Publisher<T>, Emitter<T> {
|
|
57
|
+
/** @internal */
|
|
58
|
+
(action: SUBSCRIBE | PUBLISH | RESET | VALUE): any;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Subscribes the specified [[Subscription]] to the updates from the Emitter.
|
|
62
|
+
* The emitter calls the subscription with the new data each time new data is published into it.
|
|
63
|
+
*
|
|
64
|
+
* ```ts
|
|
65
|
+
* const foo = stream<number>();
|
|
66
|
+
* subscribe(foo, (value) => console.log(value));
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @returns an [[Unsubscribe]] handle - calling it will unbind the subscription from the emitter.
|
|
70
|
+
*```ts
|
|
71
|
+
* const foo = stream<number>();
|
|
72
|
+
* const unsub = subscribe(foo, (value) => console.log(value));
|
|
73
|
+
* unsub();
|
|
74
|
+
*```
|
|
75
|
+
*/
|
|
76
|
+
export declare function subscribe<T>(emitter: Emitter<T>, subscription: Subscription<T>): Unsubscribe;
|
|
77
|
+
/**
|
|
78
|
+
* Publishes the value into the passed [[Publisher]].
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* const foo = stream<number>();
|
|
82
|
+
* publish(foo, 42);
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare function publish<T>(publisher: Publisher<T>, value: T): void;
|
|
86
|
+
/**
|
|
87
|
+
* Clears all subscriptions from the [[Emitter]].
|
|
88
|
+
* ```ts
|
|
89
|
+
* const foo = stream<number>();
|
|
90
|
+
* subscribe(foo, (value) => console.log(value));
|
|
91
|
+
* reset(foo);
|
|
92
|
+
* publish(foo, 42);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function reset(emitter: Emitter<any>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Extracts the current value from a stateful stream. Use it only as an escape hatch, as it violates the concept of reactive programming.
|
|
98
|
+
* ```ts
|
|
99
|
+
* const foo = statefulStream(42);
|
|
100
|
+
* console.log(getValue(foo));
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function getValue<T>(depot: StatefulStream<T>): T;
|
|
104
|
+
/**
|
|
105
|
+
* Connects two streams - any value emitted from the emitter will be published in the publisher.
|
|
106
|
+
* ```ts
|
|
107
|
+
* const foo = stream<number>();
|
|
108
|
+
* const bar = stream<number>();
|
|
109
|
+
* subscribe(bar, (value) => console.log(`Bar emitted ${value}`));
|
|
110
|
+
*
|
|
111
|
+
* connect(foo, bar);
|
|
112
|
+
* publish(foo);
|
|
113
|
+
* ```
|
|
114
|
+
* @returns an [[Unsubscribe]] handle which will disconnect the two streams.
|
|
115
|
+
*/
|
|
116
|
+
export declare function connect<T>(emitter: Emitter<T>, publisher: Publisher<any>): Unsubscribe;
|
|
117
|
+
/**
|
|
118
|
+
* Executes the passed subscription at most once, for the next emit from the emitter.
|
|
119
|
+
* ```ts
|
|
120
|
+
* const foo = stream<number>()
|
|
121
|
+
* handleNext(foo, value => console.log(value)) // called once, with 42
|
|
122
|
+
* publish(foo, 42)
|
|
123
|
+
* publish(foo, 43)
|
|
124
|
+
* ```
|
|
125
|
+
* @returns an [[Unsubscribe]] handle to unbind the subscription if necessary.
|
|
126
|
+
*/
|
|
127
|
+
export declare function handleNext<T>(emitter: Emitter<T>, subscription: Subscription<T>): Unsubscribe;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* urx Actions operate on streams - `publish` publishes data in a stream, and `subscribe` attaches a subscription to a stream.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
var constants_1 = require("./constants");
|
|
8
|
+
var utils_1 = require("./utils");
|
|
9
|
+
/**
|
|
10
|
+
* Subscribes the specified [[Subscription]] to the updates from the Emitter.
|
|
11
|
+
* The emitter calls the subscription with the new data each time new data is published into it.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* const foo = stream<number>();
|
|
15
|
+
* subscribe(foo, (value) => console.log(value));
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @returns an [[Unsubscribe]] handle - calling it will unbind the subscription from the emitter.
|
|
19
|
+
*```ts
|
|
20
|
+
* const foo = stream<number>();
|
|
21
|
+
* const unsub = subscribe(foo, (value) => console.log(value));
|
|
22
|
+
* unsub();
|
|
23
|
+
*```
|
|
24
|
+
*/
|
|
25
|
+
function subscribe(emitter, subscription) {
|
|
26
|
+
return emitter(constants_1.SUBSCRIBE, subscription);
|
|
27
|
+
}
|
|
28
|
+
exports.subscribe = subscribe;
|
|
29
|
+
/**
|
|
30
|
+
* Publishes the value into the passed [[Publisher]].
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const foo = stream<number>();
|
|
34
|
+
* publish(foo, 42);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
function publish(publisher, value) {
|
|
38
|
+
publisher(constants_1.PUBLISH, value);
|
|
39
|
+
}
|
|
40
|
+
exports.publish = publish;
|
|
41
|
+
/**
|
|
42
|
+
* Clears all subscriptions from the [[Emitter]].
|
|
43
|
+
* ```ts
|
|
44
|
+
* const foo = stream<number>();
|
|
45
|
+
* subscribe(foo, (value) => console.log(value));
|
|
46
|
+
* reset(foo);
|
|
47
|
+
* publish(foo, 42);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function reset(emitter) {
|
|
51
|
+
emitter(constants_1.RESET);
|
|
52
|
+
}
|
|
53
|
+
exports.reset = reset;
|
|
54
|
+
/**
|
|
55
|
+
* Extracts the current value from a stateful stream. Use it only as an escape hatch, as it violates the concept of reactive programming.
|
|
56
|
+
* ```ts
|
|
57
|
+
* const foo = statefulStream(42);
|
|
58
|
+
* console.log(getValue(foo));
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
function getValue(depot) {
|
|
62
|
+
return depot(constants_1.VALUE);
|
|
63
|
+
}
|
|
64
|
+
exports.getValue = getValue;
|
|
65
|
+
/**
|
|
66
|
+
* Connects two streams - any value emitted from the emitter will be published in the publisher.
|
|
67
|
+
* ```ts
|
|
68
|
+
* const foo = stream<number>();
|
|
69
|
+
* const bar = stream<number>();
|
|
70
|
+
* subscribe(bar, (value) => console.log(`Bar emitted ${value}`));
|
|
71
|
+
*
|
|
72
|
+
* connect(foo, bar);
|
|
73
|
+
* publish(foo);
|
|
74
|
+
* ```
|
|
75
|
+
* @returns an [[Unsubscribe]] handle which will disconnect the two streams.
|
|
76
|
+
*/
|
|
77
|
+
function connect(emitter, publisher) {
|
|
78
|
+
return subscribe(emitter, utils_1.curry2to1(publisher, constants_1.PUBLISH));
|
|
79
|
+
}
|
|
80
|
+
exports.connect = connect;
|
|
81
|
+
/**
|
|
82
|
+
* Executes the passed subscription at most once, for the next emit from the emitter.
|
|
83
|
+
* ```ts
|
|
84
|
+
* const foo = stream<number>()
|
|
85
|
+
* handleNext(foo, value => console.log(value)) // called once, with 42
|
|
86
|
+
* publish(foo, 42)
|
|
87
|
+
* publish(foo, 43)
|
|
88
|
+
* ```
|
|
89
|
+
* @returns an [[Unsubscribe]] handle to unbind the subscription if necessary.
|
|
90
|
+
*/
|
|
91
|
+
function handleNext(emitter, subscription) {
|
|
92
|
+
var unsub = emitter(constants_1.SUBSCRIBE, function (value) {
|
|
93
|
+
unsub();
|
|
94
|
+
subscription(value);
|
|
95
|
+
});
|
|
96
|
+
return unsub;
|
|
97
|
+
}
|
|
98
|
+
exports.handleNext = handleNext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PUBLISH: 0;
|
|
2
|
+
export declare type PUBLISH = typeof PUBLISH;
|
|
3
|
+
export declare const SUBSCRIBE: 1;
|
|
4
|
+
export declare type SUBSCRIBE = typeof SUBSCRIBE;
|
|
5
|
+
export declare const RESET: 2;
|
|
6
|
+
export declare type RESET = typeof RESET;
|
|
7
|
+
export declare const VALUE: 4;
|
|
8
|
+
export declare type VALUE = typeof VALUE;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./streams"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./transformers"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./pipe"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./actions"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./system"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { Emitter } from './actions';
|
|
2
|
+
/**
|
|
3
|
+
* Operators can transform and control the flow of values.
|
|
4
|
+
* [[pipe]] is used to transform one Emitter into another by stacking operators to its values.
|
|
5
|
+
* To build your own operator that looks like the built-in ones,
|
|
6
|
+
* create a function which returns an operator.
|
|
7
|
+
* The following custom operator multiplies the passed value:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* function multiplyBy(multiplier: number): Operator<number> {
|
|
11
|
+
* return done => value => done(value * multiplier)
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* const foo = stream<number>()
|
|
15
|
+
* const multipliedFoo = pipe(foo, multiplyBy(3))
|
|
16
|
+
* subscribe(multipliedFoo, value => console.log(value))
|
|
17
|
+
* publish(foo, 42)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export interface Operator<Input, Output = Input> {
|
|
21
|
+
(done: (value: Output) => void): (value: Input) => void;
|
|
22
|
+
}
|
|
23
|
+
/** @internal */
|
|
24
|
+
declare type O<I, OP> = Operator<I, OP>;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new emitter from the passed one by piping its values through one or more operators.
|
|
27
|
+
* Operators can perform various actions like filter values, pull values from other emitters, or compute new values.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const foo = stream<number>()
|
|
31
|
+
*
|
|
32
|
+
* // create an emitter that first adds 2 to the passed value, then multiplies it by * 2
|
|
33
|
+
* const bar = pipe(foo, map(value => value + 2), map(value => value * 2))
|
|
34
|
+
* subscribe(bar, value => console.log(value))
|
|
35
|
+
* publish(foo, 2) // outputs 8
|
|
36
|
+
* ```
|
|
37
|
+
* #### Sharing Subscription Calculations
|
|
38
|
+
*
|
|
39
|
+
* `pipe` acts as a proxy for the source emitter, and re-runs the operators for each subscription to the derived emitter.
|
|
40
|
+
* Use [[streamFromEmitter]] or [[statefulStreamFromEmitter]] to avoid that.
|
|
41
|
+
*/
|
|
42
|
+
export declare function pipe<T>(s: Emitter<T>): Emitter<T>;
|
|
43
|
+
export declare function pipe<T, O1>(s: Emitter<T>, o1: O<T, O1>): Emitter<O1>;
|
|
44
|
+
export declare function pipe<T, O1, O2>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>]): Emitter<O2>;
|
|
45
|
+
export declare function pipe<T, O1, O2, O3>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>, O<O2, O3>]): Emitter<O3>;
|
|
46
|
+
export declare function pipe<T, O1, O2, O3, O4>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>, O<O2, O3>, O<O3, O4>]): Emitter<O4>;
|
|
47
|
+
export declare function pipe<T, O1, O2, O3, O4, O5>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>, O<O2, O3>, O<O3, O4>, O<O4, O5>]): Emitter<O5>;
|
|
48
|
+
export declare function pipe<T, O1, O2, O3, O4, O5, O6>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>, O<O2, O3>, O<O3, O4>, O<O4, O5>, O<O5, O6>]): Emitter<O6>;
|
|
49
|
+
export declare function pipe<T, O1, O2, O3, O4, O5, O6, O7>(s: Emitter<T>, ...o: [O<T, O1>, O<O1, O2>, O<O2, O3>, O<O3, O4>, O<O4, O5>, O<O5, O6>, O<O6, O7>]): Emitter<O7>;
|
|
50
|
+
/**
|
|
51
|
+
* A function which determines if two values are equal.
|
|
52
|
+
* Implement custom comparators when [[distinctUntilChanged]] needs to work on non-primitive objects.
|
|
53
|
+
* @returns true if values should be considered equal.
|
|
54
|
+
*/
|
|
55
|
+
export interface Comparator<T> {
|
|
56
|
+
(previous: T, next: T): boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The default [[Comparator]] for [[distinctUntilChanged]] and [[duc]].
|
|
60
|
+
*/
|
|
61
|
+
export declare function defaultComparator<T>(previous: T, next: T): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Filters out identical values. Pass an optional [[Comparator]] if you need to filter non-primitive values.
|
|
64
|
+
* ```ts
|
|
65
|
+
* const foo = stream<number>()
|
|
66
|
+
*
|
|
67
|
+
* subscribe(
|
|
68
|
+
* pipe(foo, distinctUntilChanged()),
|
|
69
|
+
* console.log
|
|
70
|
+
* ) // will be called only once
|
|
71
|
+
*
|
|
72
|
+
* publish(foo, 42)
|
|
73
|
+
* publish(foo, 42)
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function distinctUntilChanged<T>(comparator?: Comparator<T>): Operator<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Filters out values for which the predicator does not return `true`-ish.
|
|
79
|
+
* ```ts
|
|
80
|
+
* const foo = stream<number>()
|
|
81
|
+
*
|
|
82
|
+
* subscribe(
|
|
83
|
+
* pipe(foo, filter(value => value % 2 === 0)),
|
|
84
|
+
* console.log
|
|
85
|
+
* ) // will be called only with even values
|
|
86
|
+
*
|
|
87
|
+
* publish(foo, 2)
|
|
88
|
+
* publish(foo, 3)
|
|
89
|
+
* publish(foo, 4)
|
|
90
|
+
* publish(foo, 5)
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function filter<T>(predicate: (value: T) => boolean): Operator<T>;
|
|
94
|
+
/**
|
|
95
|
+
* Maps values using the provided project function.
|
|
96
|
+
* ```ts
|
|
97
|
+
* const foo = stream<number>()
|
|
98
|
+
*
|
|
99
|
+
* subscribe(
|
|
100
|
+
* pipe(foo, map(value => value * 2)),
|
|
101
|
+
* console.log
|
|
102
|
+
* ) // 4, 6
|
|
103
|
+
*
|
|
104
|
+
* publish(foo, 2)
|
|
105
|
+
* publish(foo, 3)
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function map<T, K>(project: (value: T) => K): Operator<T, K>;
|
|
109
|
+
/**
|
|
110
|
+
* Maps values to the hard-coded value.
|
|
111
|
+
* ```ts
|
|
112
|
+
* const foo = stream<number>()
|
|
113
|
+
*
|
|
114
|
+
* subscribe(
|
|
115
|
+
* pipe(foo, mapTo(3)),
|
|
116
|
+
* console.log
|
|
117
|
+
* ) // 3, 3
|
|
118
|
+
*
|
|
119
|
+
* publish(foo, 1)
|
|
120
|
+
* publish(foo, 2)
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function mapTo<T>(value: T): Operator<unknown, T>;
|
|
124
|
+
/**
|
|
125
|
+
* Works like Array#reduce.
|
|
126
|
+
* Applies an accumulator function on the emitter, and outputs intermediate result. Starts with the initial value.
|
|
127
|
+
* ```ts
|
|
128
|
+
* const foo = stream<number>()
|
|
129
|
+
*
|
|
130
|
+
* subscribe(
|
|
131
|
+
* pipe(foo, scan((acc, value) => acc + value, 2),
|
|
132
|
+
* console.log
|
|
133
|
+
* ) // 3, 5
|
|
134
|
+
*
|
|
135
|
+
* publish(foo, 1)
|
|
136
|
+
* publish(foo, 2)
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export declare function scan<T, K>(scanner: (current: T, value: K) => T, initial: T): Operator<K, T>;
|
|
140
|
+
/**
|
|
141
|
+
* Skips the specified amount of values from the emitter.
|
|
142
|
+
* ```ts
|
|
143
|
+
* const foo = stream<number>()
|
|
144
|
+
*
|
|
145
|
+
* subscribe(
|
|
146
|
+
* pipe(foo, skip(2)),
|
|
147
|
+
* console.log
|
|
148
|
+
* ) // 3, 4
|
|
149
|
+
*
|
|
150
|
+
* publish(foo, 1) // skipped
|
|
151
|
+
* publish(foo, 2) // skipped
|
|
152
|
+
* publish(foo, 3)
|
|
153
|
+
* publish(foo, 4)
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function skip<T>(times: number): Operator<T>;
|
|
157
|
+
/**
|
|
158
|
+
* Throttles flowing values at the provided interval in milliseconds.
|
|
159
|
+
* [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* const foo = stream<number>()
|
|
163
|
+
* publish(foo, 1)
|
|
164
|
+
*
|
|
165
|
+
* setTimeout(() => publish(foo, 2), 20)
|
|
166
|
+
* setTimeout(() => publish(foo, 3), 20)
|
|
167
|
+
*
|
|
168
|
+
* subscribe(pipe(foo, throttleTime(50)), val => {
|
|
169
|
+
* console.log(value); // 3
|
|
170
|
+
* })
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function throttleTime<T>(interval: number): Operator<T>;
|
|
174
|
+
/**
|
|
175
|
+
* Debounces flowing values at the provided interval in milliseconds.
|
|
176
|
+
* [Throttle VS Debounce in SO](https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function).
|
|
177
|
+
*
|
|
178
|
+
* ```ts
|
|
179
|
+
* const foo = stream<number>()
|
|
180
|
+
* publish(foo, 1)
|
|
181
|
+
*
|
|
182
|
+
* setTimeout(() => publish(foo, 2), 20)
|
|
183
|
+
* setTimeout(() => publish(foo, 3), 20)
|
|
184
|
+
*
|
|
185
|
+
* subscribe(pipe(foo, debounceTime(50)), val => {
|
|
186
|
+
* console.log(value); // 3
|
|
187
|
+
* })
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
190
|
+
export declare function debounceTime<T>(interval: number): Operator<T>;
|
|
191
|
+
/**
|
|
192
|
+
* Combines the source Emitter with the latest values from the specified Emitters into an array. Outputs only when the source Emitter emits.
|
|
193
|
+
* See [[combineLatest]] for a transformer that outputs when any of the emitters emit.
|
|
194
|
+
*
|
|
195
|
+
* ```ts
|
|
196
|
+
* const foo = stream<number>()
|
|
197
|
+
* const bar = stream<number>()
|
|
198
|
+
* subscribe(
|
|
199
|
+
* pipe(
|
|
200
|
+
* foo,
|
|
201
|
+
* withLatestFrom(bar)
|
|
202
|
+
* ),
|
|
203
|
+
* (([foo, bar]) => console.log({ foo, bar }))
|
|
204
|
+
* )
|
|
205
|
+
*
|
|
206
|
+
* publish(foo, 1) // nothing happens, bar has not emitted yet
|
|
207
|
+
* publish(bar, 1) // still nothing
|
|
208
|
+
* publish(foo, 2) // logs { foo: 2, bar: 1 }
|
|
209
|
+
* publish(bar, 2)
|
|
210
|
+
* publish(foo, 3) // logs { foo: 3, bar: 2 }
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export declare function withLatestFrom<T, R1>(...s: [Emitter<R1>]): Operator<T, [T, R1]>;
|
|
214
|
+
export declare function withLatestFrom<T, R1, R2>(...s: [Emitter<R1>, Emitter<R2>]): Operator<T, [T, R1, R2]>;
|
|
215
|
+
export declare function withLatestFrom<T, R1, R2, R3>(...s: [Emitter<R1>, Emitter<R2>, Emitter<R3>]): Operator<T, [T, R1, R2, R3]>;
|
|
216
|
+
export declare function withLatestFrom<T, R1, R2, R3, R4>(...s: [Emitter<R1>, Emitter<R2>, Emitter<R3>, Emitter<R4>]): Operator<T, [T, R1, R2, R3, R4]>;
|
|
217
|
+
export declare function withLatestFrom<T, R1, R2, R3, R4, R5>(...s: [Emitter<R1>, Emitter<R2>, Emitter<R3>, Emitter<R4>, Emitter<R5>]): Operator<T, [T, R1, R2, R3, R4, R5]>;
|
|
218
|
+
export declare function withLatestFrom<T, R1, R2, R3, R4, R5, R6>(...s: [Emitter<R1>, Emitter<R2>, Emitter<R3>, Emitter<R4>, Emitter<R5>, Emitter<R6>]): Operator<T, [T, R1, R2, R3, R4, R5, R6]>;
|
|
219
|
+
export declare function withLatestFrom<T, R1, R2, R3, R4, R5, R6, R7>(...s: [Emitter<R1>, Emitter<R2>, Emitter<R3>, Emitter<R4>, Emitter<R5>, Emitter<R6>, Emitter<R7>]): Operator<T, [T, R1, R2, R3, R4, R5, R6, R7]>;
|
|
220
|
+
export {};
|