core-3nweb-client-lib 0.41.10 → 0.41.11

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.
@@ -7,6 +7,11 @@ type Observer<T> = web3n.Observer<T>;
7
7
  * Instance of this class handles event subscription from UI side. It observes
8
8
  * inbox server events, handles them, and generates respective events for UI
9
9
  * side.
10
+ *
11
+ * Event stream should hide complexity of going offline, may be sleeping and
12
+ * waking. Consumer should see messages coming, and internally this needs to
13
+ * be opportunistically connected, as long as there are subscribers to messages.
14
+ * Hence, this should do restarts to server around wakeup events.
10
15
  */
11
16
  export declare class InboxEvents {
12
17
  constructor(msgReceiver: MailRecipient, getMsg: (msgId: string) => Promise<IncomingMessage>, logError: LogError);
@@ -25,12 +25,22 @@ const SERVER_EVENTS_RESTART_WAIT_SECS = 30;
25
25
  * Instance of this class handles event subscription from UI side. It observes
26
26
  * inbox server events, handles them, and generates respective events for UI
27
27
  * side.
28
+ *
29
+ * Event stream should hide complexity of going offline, may be sleeping and
30
+ * waking. Consumer should see messages coming, and internally this needs to
31
+ * be opportunistically connected, as long as there are subscribers to messages.
32
+ * Hence, this should do restarts to server around wakeup events.
28
33
  */
29
34
  class InboxEvents {
30
35
  constructor(msgReceiver, getMsg, logError) {
31
- const serverEvents = new server_events_1.ServerEvents(() => msgReceiver.openEventSource(), SERVER_EVENTS_RESTART_WAIT_SECS);
36
+ const serverEvents = new server_events_1.ServerEvents(() => msgReceiver.openEventSource(), SERVER_EVENTS_RESTART_WAIT_SECS, logError);
32
37
  this.newMsg$ = serverEvents.observe(retrieval_1.msgRecievedCompletely.EVENT_NAME)
33
- .pipe((0, operators_1.mergeMap)(async (ev) => {
38
+ .pipe(
39
+ // XXX tap to log more details
40
+ (0, operators_1.tap)({
41
+ complete: () => logError({}, `InboxEvents.newMsg$ completes`),
42
+ error: err => logError(err, `InboxEvents.newMsg$ has error`)
43
+ }), (0, operators_1.mergeMap)(async (ev) => {
34
44
  try {
35
45
  const msg = await getMsg(ev.msgId);
36
46
  return msg;
@@ -36,7 +36,7 @@ class RemoteEvents {
36
36
  Object.seal(this);
37
37
  }
38
38
  startAbsorbingRemoteEvents() {
39
- const serverEvents = new server_events_1.ServerEvents(() => this.remoteStorage.openEventSource(), SERVER_EVENTS_RESTART_WAIT_SECS);
39
+ const serverEvents = new server_events_1.ServerEvents(() => this.remoteStorage.openEventSource(), SERVER_EVENTS_RESTART_WAIT_SECS, this.logError);
40
40
  this.absorbingRemoteEventsProc = (0, rxjs_1.merge)(this.absorbObjChange(serverEvents), this.absorbObjRemoval(serverEvents), this.absorbObjVersionArchival(serverEvents), this.absorbArchVersionRemoval(serverEvents))
41
41
  .subscribe({
42
42
  next: noop,