@fraym/streams 0.10.3 → 0.10.4
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/dist/client/stream.js +9 -0
- package/package.json +1 -1
package/dist/client/stream.js
CHANGED
|
@@ -6,10 +6,14 @@ const util_1 = require("./util");
|
|
|
6
6
|
const publish_1 = require("./publish");
|
|
7
7
|
const getStream = async (topic, tenantId, stream, perPage, handler, stopLoadingMore, serviceClient) => {
|
|
8
8
|
let lastEventId = null;
|
|
9
|
+
let possibleSnapshotEventId = null;
|
|
9
10
|
let events = [];
|
|
10
11
|
while (true) {
|
|
11
12
|
if (!lastEventId) {
|
|
12
13
|
events = await getStreamPage(topic, tenantId, stream, perPage, 0, serviceClient);
|
|
14
|
+
if (events.length > 0) {
|
|
15
|
+
possibleSnapshotEventId = events[0].id;
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
19
|
events = await getStreamPageAfterEvent(topic, tenantId, stream, lastEventId, perPage, 0, serviceClient);
|
|
@@ -18,6 +22,11 @@ const getStream = async (topic, tenantId, stream, perPage, handler, stopLoadingM
|
|
|
18
22
|
for (const eventData of events) {
|
|
19
23
|
const event = (0, event_1.getSubscriptionEvent)(eventData);
|
|
20
24
|
if (event) {
|
|
25
|
+
if (lastEventId != null && possibleSnapshotEventId) {
|
|
26
|
+
if (event.id === possibleSnapshotEventId) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
21
30
|
await handler(event);
|
|
22
31
|
lastEvent = event;
|
|
23
32
|
lastEventId = event.id;
|