@opentap/runner-client 1.2.1-beta.3 → 1.2.1-beta.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.
@@ -2,6 +2,8 @@ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Int
2
2
  import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws/cjs/nats.js';
3
3
  import { BaseClient } from './BaseClient';
4
4
  export declare class SessionClient extends BaseClient {
5
+ private eventsSubscription;
6
+ private eventsWildcardSubscription;
5
7
  constructor(baseSubject: string, options: ConnectionOptions);
6
8
  /**
7
9
  * @param sessionLogsHandler Function to be called when log list or error is received
@@ -14,7 +16,7 @@ export declare class SessionClient extends BaseClient {
14
16
  * @param options (optional) Subscription options
15
17
  * @returns Subscription object
16
18
  */
17
- connectSessionEvents(eventHandler: (sessionEvent: SessionEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
19
+ connectSessionEvents(eventHandler: (sessionEvent: SessionEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): void;
18
20
  /**
19
21
  * @param resultHandler Function to be called when result or error is received
20
22
  * @param testRunHandler Function to be called when test run or error is received
@@ -22,6 +24,10 @@ export declare class SessionClient extends BaseClient {
22
24
  * @returns Subscription array: Result and Test Run subscriptions
23
25
  */
24
26
  connectSessionResults(resultHandler: (result: Result | undefined, err: NatsError | Error | null) => void, testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): [Subscription, Subscription];
27
+ /**
28
+ * Unsubscibe from session events
29
+ */
30
+ unsubscribeSessionEvents(): void;
25
31
  /**
26
32
  * Retrieve session logs
27
33
  * @param id (optional)
@@ -60,21 +60,23 @@ var SessionClient = /** @class */ (function (_super) {
60
60
  * @returns Subscription object
61
61
  */
62
62
  SessionClient.prototype.connectSessionEvents = function (eventHandler, options) {
63
- return this.subscribe('Events.*', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
64
- if (error) {
65
- eventHandler(undefined, error);
66
- return;
67
- }
68
- try {
69
- var jsonCodec = JSONCodec();
70
- var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
71
- var sessionEvent = SessionEvent.fromJS(sessionEventJs);
72
- eventHandler(sessionEvent, error);
73
- }
74
- catch (error) {
75
- eventHandler(undefined, error);
76
- }
77
- } }));
63
+ var callback = function (error, encodedMessage) {
64
+ if (error) {
65
+ eventHandler(undefined, error);
66
+ return;
67
+ }
68
+ try {
69
+ var jsonCodec = JSONCodec();
70
+ var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
71
+ var sessionEvent = SessionEvent.fromJS(sessionEventJs);
72
+ eventHandler(sessionEvent, error);
73
+ }
74
+ catch (error) {
75
+ eventHandler(undefined, error);
76
+ }
77
+ };
78
+ this.eventsSubscription = this.subscribe('Events', __assign(__assign({}, options), { callback: callback }));
79
+ this.eventsWildcardSubscription = this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback }));
78
80
  };
79
81
  /**
80
82
  * @param resultHandler Function to be called when result or error is received
@@ -116,6 +118,17 @@ var SessionClient = /** @class */ (function (_super) {
116
118
  } })),
117
119
  ];
118
120
  };
121
+ /**
122
+ * Unsubscibe from session events
123
+ */
124
+ SessionClient.prototype.unsubscribeSessionEvents = function () {
125
+ if (this.eventsSubscription) {
126
+ this.eventsSubscription.unsubscribe();
127
+ }
128
+ if (this.eventsWildcardSubscription) {
129
+ this.eventsWildcardSubscription.unsubscribe();
130
+ }
131
+ };
119
132
  /**
120
133
  * Retrieve session logs
121
134
  * @param id (optional)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "1.2.1-beta.3",
3
+ "version": "1.2.1-beta.4",
4
4
  "description": "This is the web client for the OpenTAP Runner.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",