@nmshd/app-runtime 2.0.0-alpha.3 → 2.0.0-alpha.6
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 +2 -2
- package/dist/buildInformation.js +5 -5
- package/dist/events/MailReceivedEvent.d.ts +3 -3
- package/dist/events/MailReceivedEvent.js.map +1 -1
- package/dist/events/RequestReceivedEvent.d.ts +4 -4
- package/dist/events/RequestReceivedEvent.js.map +1 -1
- package/dist/extensibility/ui/IUIBridge.d.ts +2 -2
- package/dist/modules/AppRuntimeModule.d.ts +1 -1
- package/dist/modules/AppRuntimeModule.js +4 -6
- package/dist/modules/AppRuntimeModule.js.map +1 -1
- package/dist/modules/runtimeEvents/MessageReceivedModule.js +2 -6
- package/dist/modules/runtimeEvents/MessageReceivedModule.js.map +1 -1
- package/lib-web/nmshd.app-runtime.js +57 -38
- package/lib-web/nmshd.app-runtime.min.js +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ The App-Runtime extends the Runtime with App-specific functionality.
|
|
|
7
7
|
|
|
8
8
|
## Documentation
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
You can find the documentation for Enmeshed on [enmeshed.eu](https://enmeshed.eu).
|
|
11
11
|
|
|
12
12
|
## Feedback
|
|
13
13
|
|
|
@@ -17,7 +17,7 @@ Share your feedback with the Enmeshed team by contributing to the [discussions](
|
|
|
17
17
|
|
|
18
18
|
## Contribute
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Contribution to this project is highly apprecicated. Head over to our [contribution guide](https://github.com/nmshd/.github/blob/main/CONTRIBUTING.md) to learn more.
|
|
21
21
|
|
|
22
22
|
## License
|
|
23
23
|
|
package/dist/buildInformation.js
CHANGED
|
@@ -8,11 +8,11 @@ const crypto_1 = require("@nmshd/crypto");
|
|
|
8
8
|
const runtime_1 = require("@nmshd/runtime");
|
|
9
9
|
const transport_1 = require("@nmshd/transport");
|
|
10
10
|
exports.buildInformation = {
|
|
11
|
-
version: "2.0.0-alpha.
|
|
12
|
-
build: "
|
|
13
|
-
date: "2022-07-
|
|
14
|
-
commit: "
|
|
15
|
-
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.
|
|
11
|
+
version: "2.0.0-alpha.6",
|
|
12
|
+
build: "17",
|
|
13
|
+
date: "2022-07-19T13:27:53+00:00",
|
|
14
|
+
commit: "6fac45e109bc1f82f4cb7010552b612291f3c297",
|
|
15
|
+
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-alpha.37","lodash":"^4.17.21"},
|
|
16
16
|
libraries: {
|
|
17
17
|
serval: ts_serval_1.buildInformation,
|
|
18
18
|
crypto: crypto_1.buildInformation,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataEvent, MailDVO
|
|
2
|
-
export declare class MailReceivedEvent extends DataEvent<MailDVO
|
|
1
|
+
import { DataEvent, MailDVO } from "@nmshd/runtime";
|
|
2
|
+
export declare class MailReceivedEvent extends DataEvent<MailDVO> {
|
|
3
3
|
static readonly namespace: string;
|
|
4
|
-
constructor(address: string, message: MailDVO
|
|
4
|
+
constructor(address: string, message: MailDVO);
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MailReceivedEvent.js","sourceRoot":"","sources":["../../src/events/MailReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"MailReceivedEvent.js","sourceRoot":"","sources":["../../src/events/MailReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAAmD;AAEnD,MAAa,iBAAkB,SAAQ,mBAAkB;IAGrD,YAAmB,OAAe,EAAE,OAAgB;QAChD,KAAK,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;;AALL,8CAMC;AAL0B,2BAAS,GAAW,kBAAkB,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DataEvent,
|
|
1
|
+
import { DataEvent, LocalRequestDVO, RequestMessageDVO } from "@nmshd/runtime";
|
|
2
2
|
export declare class RequestReceivedEvent extends DataEvent<{
|
|
3
|
-
request:
|
|
4
|
-
message:
|
|
3
|
+
request: LocalRequestDVO;
|
|
4
|
+
message: RequestMessageDVO;
|
|
5
5
|
}> {
|
|
6
6
|
static readonly namespace: string;
|
|
7
|
-
constructor(address: string, request:
|
|
7
|
+
constructor(address: string, request: LocalRequestDVO, message: RequestMessageDVO);
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestReceivedEvent.js","sourceRoot":"","sources":["../../src/events/RequestReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"RequestReceivedEvent.js","sourceRoot":"","sources":["../../src/events/RequestReceivedEvent.ts"],"names":[],"mappings":";;;AAAA,4CAA8E;AAE9E,MAAa,oBAAqB,SAAQ,mBAGxC;IAGE,YAAmB,OAAe,EAAE,OAAwB,EAAE,OAA0B;QACpF,KAAK,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE;YAC3C,OAAO;YACP,OAAO;SACV,CAAC,CAAA;IACN,CAAC;;AAXL,oDAYC;AAR0B,8BAAS,GAAW,qBAAqB,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Result } from "@js-soft/ts-utils";
|
|
2
|
-
import { IdentityDVO, MailDVO, MessageDVO, RelationshipChangeDTO, RelationshipTemplateDTO,
|
|
2
|
+
import { IdentityDVO, MailDVO, MessageDVO, RelationshipChangeDTO, RelationshipTemplateDTO, RequestMessageDVO, TokenDTO } from "@nmshd/runtime";
|
|
3
3
|
import { LocalAccountDTO } from "../../multiAccount";
|
|
4
4
|
import { UserfriendlyApplicationError } from "../../UserfriendlyApplicationError";
|
|
5
5
|
export interface IUIBridge {
|
|
6
|
-
showMessage(account: LocalAccountDTO, relationship: IdentityDVO, message: MessageDVO | MailDVO |
|
|
6
|
+
showMessage(account: LocalAccountDTO, relationship: IdentityDVO, message: MessageDVO | MailDVO | RequestMessageDVO): Promise<Result<void>>;
|
|
7
7
|
showRelationship(account: LocalAccountDTO, relationship: IdentityDVO): Promise<Result<void>>;
|
|
8
8
|
showRelationshipChange(account: LocalAccountDTO, relationship: IdentityDVO, change: RelationshipChangeDTO): Promise<Result<void>>;
|
|
9
9
|
showRelationshipTemplate(account: LocalAccountDTO, relationshipTemplate: RelationshipTemplateDTO): Promise<Result<void>>;
|
|
@@ -8,7 +8,7 @@ export interface IAppRuntimeModuleConstructor {
|
|
|
8
8
|
export interface AppRuntimeModuleConfiguration extends ModuleConfiguration {
|
|
9
9
|
}
|
|
10
10
|
export declare abstract class AppRuntimeModule<TConfig extends AppRuntimeModuleConfiguration = AppRuntimeModuleConfiguration> extends RuntimeModule<TConfig, AppRuntime> {
|
|
11
|
-
private readonly
|
|
11
|
+
private readonly nativeEventSubscriptionIds;
|
|
12
12
|
protected subscribeToNativeEvent<TEvent>(event: Event, handler: EventHandler<TEvent>): void;
|
|
13
13
|
protected unsubscribeFromAllEvents(): void;
|
|
14
14
|
}
|
|
@@ -5,7 +5,7 @@ const runtime_1 = require("@nmshd/runtime");
|
|
|
5
5
|
class AppRuntimeModule extends runtime_1.RuntimeModule {
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
|
-
this.
|
|
8
|
+
this.nativeEventSubscriptionIds = [];
|
|
9
9
|
}
|
|
10
10
|
subscribeToNativeEvent(event, handler) {
|
|
11
11
|
const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(event, handler);
|
|
@@ -13,14 +13,12 @@ class AppRuntimeModule extends runtime_1.RuntimeModule {
|
|
|
13
13
|
this.logger.error(subscriptionResult.error);
|
|
14
14
|
throw subscriptionResult.error;
|
|
15
15
|
}
|
|
16
|
-
this.
|
|
16
|
+
this.nativeEventSubscriptionIds.push(subscriptionResult.value);
|
|
17
17
|
}
|
|
18
18
|
unsubscribeFromAllEvents() {
|
|
19
19
|
super.unsubscribeFromAllEvents();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
this.registeredNativeEventSubscriptions.splice(0);
|
|
20
|
+
this.nativeEventSubscriptionIds.forEach((id) => this.runtime.nativeEnvironment.eventBus.unsubscribe(id));
|
|
21
|
+
this.nativeEventSubscriptionIds.splice(0);
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
exports.AppRuntimeModule = AppRuntimeModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRuntimeModule.js","sourceRoot":"","sources":["../../src/modules/AppRuntimeModule.ts"],"names":[],"mappings":";;;AAEA,4CAAmE;AASnE,MAAsB,gBAEpB,SAAQ,uBAAkC;IAF5C;;QAGqB,
|
|
1
|
+
{"version":3,"file":"AppRuntimeModule.js","sourceRoot":"","sources":["../../src/modules/AppRuntimeModule.ts"],"names":[],"mappings":";;;AAEA,4CAAmE;AASnE,MAAsB,gBAEpB,SAAQ,uBAAkC;IAF5C;;QAGqB,+BAA0B,GAAa,EAAE,CAAA;IAkB9D,CAAC;IAhBa,sBAAsB,CAAS,KAAY,EAAE,OAA6B;QAChF,MAAM,kBAAkB,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC5F,IAAI,kBAAkB,CAAC,OAAO,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;YAC3C,MAAM,kBAAkB,CAAC,KAAK,CAAA;SACjC;QAED,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAA;IAClE,CAAC;IAEkB,wBAAwB;QACvC,KAAK,CAAC,wBAAwB,EAAE,CAAA;QAEhC,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;QACxG,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC7C,CAAC;CACJ;AArBD,4CAqBC"}
|
|
@@ -24,12 +24,8 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
24
24
|
}
|
|
25
25
|
const messageDVO = await session.expander.expandMessageDTO(message);
|
|
26
26
|
switch (messageDVO.type) {
|
|
27
|
-
case "
|
|
28
|
-
|
|
29
|
-
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, requestMail));
|
|
30
|
-
for (const requestDVO of requestMail.requests) {
|
|
31
|
-
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, requestDVO, messageDVO));
|
|
32
|
-
}
|
|
27
|
+
case "RequestMessageDVO":
|
|
28
|
+
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
|
|
33
29
|
break;
|
|
34
30
|
case "MailDVO":
|
|
35
31
|
const mail = messageDVO;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"MessageReceivedModule.js","sourceRoot":"","sources":["../../../src/modules/runtimeEvents/MessageReceivedModule.ts"],"names":[],"mappings":";;;AAAA,4CAA8D;AAC9D,2DAAuD;AACvD,yCAAsE;AACtE,0DAAqF;AAIrF,MAAa,0BAA2B,SAAQ,iCAAe;CAAG;AAAlE,gEAAkE;AAElE,MAAa,qBAAsB,SAAQ,mCAA6C;IAC7E,KAAK,CAAC,IAAI;QACb,qBAAqB;IACzB,CAAC;IAEM,KAAK;QACR,IAAI,CAAC,gBAAgB,CAAC,8BAAoB,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IACtF,CAAC;IAEO,KAAK,CAAC,qBAAqB,CAAC,KAA2B;QAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAA;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAC3E,IAAI,CAAC,OAAO,EAAE;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,KAAK,CAAC,kBAAkB,EAAE,CAAC,CAAA;YAC7E,OAAM;SACT;QACD,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;QAEnE,QAAQ,UAAU,CAAC,IAAI,EAAE;YACrB,KAAK,mBAAmB;gBACpB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CACzB,IAAI,6BAAoB,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CACrF,CAAA;gBACD,MAAK;YACT,KAAK,SAAS;gBACV,MAAM,IAAI,GAAY,UAAU,CAAA;gBAChC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,0BAAiB,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAA;gBACpF,MAAK;YACT;gBACI,MAAK;SACZ;IACL,CAAC;IAEM,IAAI;QACP,IAAI,CAAC,wBAAwB,EAAE,CAAA;IACnC,CAAC;CACJ;AApCD,sDAoCC"}
|
|
@@ -558,11 +558,11 @@ const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
|
558
558
|
const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
|
|
559
559
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
560
560
|
exports.buildInformation = {
|
|
561
|
-
version: "2.0.0-alpha.
|
|
562
|
-
build: "
|
|
563
|
-
date: "2022-07-
|
|
564
|
-
commit: "
|
|
565
|
-
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.
|
|
561
|
+
version: "2.0.0-alpha.6",
|
|
562
|
+
build: "17",
|
|
563
|
+
date: "2022-07-19T13:27:53+00:00",
|
|
564
|
+
commit: "6fac45e109bc1f82f4cb7010552b612291f3c297",
|
|
565
|
+
dependencies: {"@js-soft/docdb-access-loki":"^1.0.3","@js-soft/native-abstractions":"^1.2.0","@nmshd/runtime":"2.0.0-alpha.37","lodash":"^4.17.21"},
|
|
566
566
|
libraries: {
|
|
567
567
|
serval: ts_serval_1.buildInformation,
|
|
568
568
|
crypto: crypto_1.buildInformation,
|
|
@@ -1143,7 +1143,7 @@ const runtime_1 = __webpack_require__(/*! @nmshd/runtime */ "@nmshd/runtime");
|
|
|
1143
1143
|
class AppRuntimeModule extends runtime_1.RuntimeModule {
|
|
1144
1144
|
constructor() {
|
|
1145
1145
|
super(...arguments);
|
|
1146
|
-
this.
|
|
1146
|
+
this.nativeEventSubscriptionIds = [];
|
|
1147
1147
|
}
|
|
1148
1148
|
subscribeToNativeEvent(event, handler) {
|
|
1149
1149
|
const subscriptionResult = this.runtime.nativeEnvironment.eventBus.subscribe(event, handler);
|
|
@@ -1151,14 +1151,12 @@ class AppRuntimeModule extends runtime_1.RuntimeModule {
|
|
|
1151
1151
|
this.logger.error(subscriptionResult.error);
|
|
1152
1152
|
throw subscriptionResult.error;
|
|
1153
1153
|
}
|
|
1154
|
-
this.
|
|
1154
|
+
this.nativeEventSubscriptionIds.push(subscriptionResult.value);
|
|
1155
1155
|
}
|
|
1156
1156
|
unsubscribeFromAllEvents() {
|
|
1157
1157
|
super.unsubscribeFromAllEvents();
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
}
|
|
1161
|
-
this.registeredNativeEventSubscriptions.splice(0);
|
|
1158
|
+
this.nativeEventSubscriptionIds.forEach((id) => this.runtime.nativeEnvironment.eventBus.unsubscribe(id));
|
|
1159
|
+
this.nativeEventSubscriptionIds.splice(0);
|
|
1162
1160
|
}
|
|
1163
1161
|
}
|
|
1164
1162
|
exports.AppRuntimeModule = AppRuntimeModule;
|
|
@@ -1674,12 +1672,8 @@ class MessageReceivedModule extends AppRuntimeModule_1.AppRuntimeModule {
|
|
|
1674
1672
|
}
|
|
1675
1673
|
const messageDVO = await session.expander.expandMessageDTO(message);
|
|
1676
1674
|
switch (messageDVO.type) {
|
|
1677
|
-
case "
|
|
1678
|
-
|
|
1679
|
-
this.runtime.eventBus.publish(new events_1.MailReceivedEvent(event.eventTargetAddress, requestMail));
|
|
1680
|
-
for (const requestDVO of requestMail.requests) {
|
|
1681
|
-
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, requestDVO, messageDVO));
|
|
1682
|
-
}
|
|
1675
|
+
case "RequestMessageDVO":
|
|
1676
|
+
this.runtime.eventBus.publish(new events_1.RequestReceivedEvent(event.eventTargetAddress, messageDVO.request, messageDVO));
|
|
1683
1677
|
break;
|
|
1684
1678
|
case "MailDVO":
|
|
1685
1679
|
const mail = messageDVO;
|
|
@@ -3222,10 +3216,11 @@ const EventBus_1 = __webpack_require__(/*! ../EventBus */ "./node_modules/@js-so
|
|
|
3222
3216
|
const SubscriptionTargetInfo_1 = __webpack_require__(/*! ../SubscriptionTargetInfo */ "./node_modules/@js-soft/ts-utils/dist/eventBus/SubscriptionTargetInfo.js");
|
|
3223
3217
|
class EventEmitter2EventBus {
|
|
3224
3218
|
emitter;
|
|
3225
|
-
|
|
3219
|
+
listeners = new Map();
|
|
3226
3220
|
nextId = 0;
|
|
3227
|
-
|
|
3228
|
-
|
|
3221
|
+
invocationPromises = [];
|
|
3222
|
+
constructor(options) {
|
|
3223
|
+
this.emitter = new eventemitter2_1.EventEmitter2({ ...options, wildcard: true, maxListeners: 50, verboseMemoryLeak: true });
|
|
3229
3224
|
}
|
|
3230
3225
|
subscribe(subscriptionTarget, handler) {
|
|
3231
3226
|
return this.registerHandler(subscriptionTarget, handler);
|
|
@@ -3233,33 +3228,39 @@ class EventEmitter2EventBus {
|
|
|
3233
3228
|
subscribeOnce(subscriptionTarget, handler) {
|
|
3234
3229
|
return this.registerHandler(subscriptionTarget, handler, true);
|
|
3235
3230
|
}
|
|
3236
|
-
unsubscribe(
|
|
3237
|
-
return this.unregisterHandler(
|
|
3231
|
+
unsubscribe(subscriptionId) {
|
|
3232
|
+
return this.unregisterHandler(subscriptionId);
|
|
3238
3233
|
}
|
|
3239
3234
|
registerHandler(subscriptionTarget, handler, isOneTimeHandler = false) {
|
|
3240
3235
|
const subscriptionTargetInfo = SubscriptionTargetInfo_1.SubscriptionTargetInfo.from(subscriptionTarget);
|
|
3241
|
-
const
|
|
3242
|
-
const handlerWrapper = (event) => {
|
|
3236
|
+
const listenerId = this.nextId++;
|
|
3237
|
+
const handlerWrapper = async (event) => {
|
|
3243
3238
|
if (!subscriptionTargetInfo.isCompatibleWith(event)) {
|
|
3244
3239
|
return;
|
|
3245
3240
|
}
|
|
3246
|
-
handler(event);
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3241
|
+
const invocationPromise = (async () => await handler(event))();
|
|
3242
|
+
this.invocationPromises.push(invocationPromise);
|
|
3243
|
+
await invocationPromise;
|
|
3244
|
+
this.invocationPromises = this.invocationPromises.filter((p) => p !== invocationPromise);
|
|
3245
|
+
if (isOneTimeHandler)
|
|
3246
|
+
this.listeners.delete(listenerId);
|
|
3250
3247
|
};
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
const
|
|
3257
|
-
|
|
3258
|
-
|
|
3248
|
+
if (isOneTimeHandler) {
|
|
3249
|
+
const listener = this.emitter.once(subscriptionTargetInfo.namespace, handlerWrapper, { objectify: true });
|
|
3250
|
+
this.listeners.set(listenerId, listener);
|
|
3251
|
+
return listenerId;
|
|
3252
|
+
}
|
|
3253
|
+
const listener = this.emitter.on(subscriptionTargetInfo.namespace, handlerWrapper, { objectify: true });
|
|
3254
|
+
this.listeners.set(listenerId, listener);
|
|
3255
|
+
return listenerId;
|
|
3256
|
+
}
|
|
3257
|
+
unregisterHandler(listenerId) {
|
|
3258
|
+
const listener = this.listeners.get(listenerId);
|
|
3259
|
+
if (!listener) {
|
|
3259
3260
|
return false;
|
|
3260
3261
|
}
|
|
3261
|
-
|
|
3262
|
-
this.
|
|
3262
|
+
listener.off();
|
|
3263
|
+
this.listeners.delete(listenerId);
|
|
3263
3264
|
return true;
|
|
3264
3265
|
}
|
|
3265
3266
|
publish(event) {
|
|
@@ -3269,6 +3270,24 @@ class EventEmitter2EventBus {
|
|
|
3269
3270
|
}
|
|
3270
3271
|
this.emitter.emit(namespace, event);
|
|
3271
3272
|
}
|
|
3273
|
+
async close(timeout) {
|
|
3274
|
+
this.emitter.removeAllListeners();
|
|
3275
|
+
const waitForInvocations = Promise.all(this.invocationPromises).catch(() => {
|
|
3276
|
+
/* ignore errors */
|
|
3277
|
+
});
|
|
3278
|
+
if (!timeout) {
|
|
3279
|
+
await waitForInvocations;
|
|
3280
|
+
return;
|
|
3281
|
+
}
|
|
3282
|
+
let timeoutId;
|
|
3283
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
3284
|
+
timeoutId = setTimeout(() => {
|
|
3285
|
+
reject(new Error("timeout exceeded while waiting for events to process"));
|
|
3286
|
+
}, timeout);
|
|
3287
|
+
});
|
|
3288
|
+
await Promise.race([waitForInvocations, timeoutPromise]);
|
|
3289
|
+
clearTimeout(timeoutId);
|
|
3290
|
+
}
|
|
3272
3291
|
}
|
|
3273
3292
|
exports.EventEmitter2EventBus = EventEmitter2EventBus;
|
|
3274
3293
|
//# sourceMappingURL=EventEmitter2EventBus.js.map
|