@slickgrid-universal/event-pub-sub 0.19.1 → 1.2.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/CHANGELOG.md CHANGED
@@ -3,7 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [0.19.1](https://github.com/ghiscoding/slickgrid-universal/compare/v0.19.0...v0.19.1) (2021-11-15)
6
+ # [1.2.0](https://github.com/ghiscoding/slickgrid-universal/compare/v1.1.1...v1.2.0) (2022-01-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **services:** unsubscribe shouldn't remove when poping out of array ([e841da9](https://github.com/ghiscoding/slickgrid-universal/commit/e841da9df7a23bf7b789e4a13803488ab479ff15))
12
+
13
+
14
+ ### Features
15
+
16
+ * **binding:** make Binding Service a little smarter ([98a7661](https://github.com/ghiscoding/slickgrid-universal/commit/98a766173638246b6a17e31812929a9bba1eb52b))
17
+ * **services:** add extra features to EventPubSub Service ([9bd02b5](https://github.com/ghiscoding/slickgrid-universal/commit/9bd02b5d92bcf6aaf89a828c4e6496a24e795c53))
18
+
19
+
20
+
21
+
22
+
23
+ ## [1.1.1](https://github.com/ghiscoding/slickgrid-universal/compare/v1.1.0...v1.1.1) (2021-12-11)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **build:** bump version manually bcoz of previous force push ([5e9a610](https://github.com/ghiscoding/slickgrid-universal/commit/5e9a610ad01d752673856591f9b5de73b0ece0e9))
29
+
30
+
31
+
32
+
33
+
34
+ # [1.1.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.19.2...v1.1.0) (2021-12-11)
7
35
 
8
36
  **Note:** Version bump only for package @slickgrid-universal/event-pub-sub
9
37
 
@@ -12,6 +40,24 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
12
40
 
13
41
 
14
42
 
43
+ ## [0.19.2](https://github.com/ghiscoding/slickgrid-universal/compare/v0.19.1...v0.19.2) (2021-11-19)
44
+
45
+ **Note:** Version bump only for package @slickgrid-universal/event-pub-sub
46
+
47
+
48
+
49
+
50
+
51
+
52
+ ## [0.19.1](https://github.com/ghiscoding/slickgrid-universal/compare/v0.19.0...v0.19.1) (2021-11-15)
53
+
54
+ **Note:** Version bump only for package @slickgrid-universal/event-pub-sub
55
+
56
+
57
+
58
+
59
+
60
+
15
61
  # [0.19.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.18.0...v0.19.0) (2021-10-28)
16
62
 
17
63
  **Note:** Version bump only for package @slickgrid-universal/event-pub-sub
@@ -1,15 +1,33 @@
1
- import { EventNamingStyle, EventSubscription, PubSubService } from '@slickgrid-universal/common';
2
- interface PubSubEvent {
1
+ import { EventNamingStyle, EventSubscription, PubSubService, Subscription } from '@slickgrid-universal/common';
2
+ export interface PubSubEvent<T = any> {
3
3
  name: string;
4
- listener: (event: CustomEventInit) => void;
4
+ listener: (event: T | CustomEventInit<T>) => void;
5
5
  }
6
6
  export declare class EventPubSubService implements PubSubService {
7
7
  protected _elementSource: Element;
8
8
  protected _subscribedEvents: PubSubEvent[];
9
9
  eventNamingStyle: EventNamingStyle;
10
+ get elementSource(): Element;
11
+ set elementSource(element: Element);
10
12
  get subscribedEvents(): PubSubEvent[];
11
13
  get subscribedEventNames(): string[];
12
14
  constructor(elementSource?: Element);
15
+ /**
16
+ * Dispatch of Custom Event, which by default will bubble up & is cancelable
17
+ * @param {String} eventName - event name to dispatch
18
+ * @param {*} data - optional data to include in the dispatching
19
+ * @param {Boolean} isBubbling - is the event bubbling up?
20
+ * @param {Boolean} isCancelable - is the event cancellable?
21
+ * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
22
+ */
23
+ dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
24
+ /**
25
+ * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
26
+ * @param {String} inputEventName - name of the event
27
+ * @param {String} eventNamePrefix - prefix to use in the event name
28
+ * @returns {String} - output event name
29
+ */
30
+ getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
13
31
  /**
14
32
  * Method to publish a message via a dispatchEvent.
15
33
  * Return is a Boolean (from the event dispatch) unless a delay is provided if so we'll return the dispatched event in a Promise with a delayed cycle
@@ -28,7 +46,7 @@ export declare class EventPubSubService implements PubSubService {
28
46
  * @param callback The callback to be invoked when the specified message is published.
29
47
  * @return possibly a Subscription
30
48
  */
31
- subscribe<T = any>(eventName: string, callback: (data: any) => void): any;
49
+ subscribe<T = any>(eventName: string, callback: (data: T) => void): Subscription;
32
50
  /**
33
51
  * Subscribes to a custom event message channel or message type.
34
52
  * This is similar to the "subscribe" except that the callback receives an event typed as CustomEventInit and the data will be inside its "event.detail"
@@ -36,18 +54,16 @@ export declare class EventPubSubService implements PubSubService {
36
54
  * @param callback The callback to be invoked when the specified message is published.
37
55
  * @return possibly a Subscription
38
56
  */
39
- subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): any | void;
57
+ subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): Subscription;
40
58
  /**
41
59
  * Unsubscribes a message name
42
- * @param event The event name
60
+ * @param {String} event - the event name
61
+ * @param {*} listener - event listener callback
62
+ * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
43
63
  * @return possibly a Subscription
44
64
  */
45
- unsubscribe(eventName: string, listener: (event: CustomEventInit) => void): void;
46
- /** Unsubscribes all subscriptions that currently exists */
65
+ unsubscribe<T = any>(eventName: string, listener: (event: T | CustomEventInit<T>) => void, shouldRemoveFromEventList?: boolean): void;
66
+ /** Unsubscribes all subscriptions/events that currently exists */
47
67
  unsubscribeAll(subscriptions?: EventSubscription[]): void;
48
- /** Dispatch of Custom Event, which by default will bubble up & is cancelable */
49
- dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
50
- /** Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case */
51
- getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
68
+ protected removeSubscribedEventWhenFound<T>(eventName: string, listener: (event: T | CustomEventInit<T>) => void): void;
52
69
  }
53
- export {};
@@ -10,12 +10,57 @@ class EventPubSubService {
10
10
  // or create a "phantom DOM node" (a div element that is never rendered) to set up a custom event dispatching
11
11
  this._elementSource = elementSource || document.createElement('div');
12
12
  }
13
+ get elementSource() {
14
+ return this._elementSource;
15
+ }
16
+ set elementSource(element) {
17
+ this._elementSource = element;
18
+ }
13
19
  get subscribedEvents() {
14
20
  return this._subscribedEvents;
15
21
  }
16
22
  get subscribedEventNames() {
17
23
  return this._subscribedEvents.map((pubSubEvent) => pubSubEvent.name);
18
24
  }
25
+ /**
26
+ * Dispatch of Custom Event, which by default will bubble up & is cancelable
27
+ * @param {String} eventName - event name to dispatch
28
+ * @param {*} data - optional data to include in the dispatching
29
+ * @param {Boolean} isBubbling - is the event bubbling up?
30
+ * @param {Boolean} isCancelable - is the event cancellable?
31
+ * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
32
+ */
33
+ dispatchCustomEvent(eventName, data, isBubbling = true, isCancelable = true) {
34
+ const eventInit = { bubbles: isBubbling, cancelable: isCancelable };
35
+ if (data) {
36
+ eventInit.detail = data;
37
+ }
38
+ return this._elementSource.dispatchEvent(new CustomEvent(eventName, eventInit));
39
+ }
40
+ /**
41
+ * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
42
+ * @param {String} inputEventName - name of the event
43
+ * @param {String} eventNamePrefix - prefix to use in the event name
44
+ * @returns {String} - output event name
45
+ */
46
+ getEventNameByNamingConvention(inputEventName, eventNamePrefix) {
47
+ let outputEventName = '';
48
+ switch (this.eventNamingStyle) {
49
+ case common_1.EventNamingStyle.camelCase:
50
+ outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${(0, common_1.titleCase)(inputEventName)}` : inputEventName;
51
+ break;
52
+ case common_1.EventNamingStyle.kebabCase:
53
+ outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${(0, common_1.toKebabCase)(inputEventName)}` : (0, common_1.toKebabCase)(inputEventName);
54
+ break;
55
+ case common_1.EventNamingStyle.lowerCase:
56
+ outputEventName = `${eventNamePrefix}${inputEventName}`.toLowerCase();
57
+ break;
58
+ case common_1.EventNamingStyle.lowerCaseWithoutOnPrefix:
59
+ outputEventName = `${eventNamePrefix}${inputEventName.replace(/^on/, '')}`.toLowerCase();
60
+ break;
61
+ }
62
+ return outputEventName;
63
+ }
19
64
  /**
20
65
  * Method to publish a message via a dispatchEvent.
21
66
  * Return is a Boolean (from the event dispatch) unless a delay is provided if so we'll return the dispatched event in a Promise with a delayed cycle
@@ -31,8 +76,7 @@ class EventPubSubService {
31
76
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
32
77
  if (delay) {
33
78
  return new Promise(resolve => {
34
- const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, true);
35
- setTimeout(() => resolve(isDispatched), delay);
79
+ setTimeout(() => resolve(this.dispatchCustomEvent(eventNameByConvention, data, true, true)), delay);
36
80
  });
37
81
  }
38
82
  else {
@@ -51,6 +95,10 @@ class EventPubSubService {
51
95
  // basically we substitute the "data" with "event.detail" so that the user ends up with only the "data" result
52
96
  this._elementSource.addEventListener(eventNameByConvention, (event) => callback.call(null, event.detail));
53
97
  this._subscribedEvents.push({ name: eventNameByConvention, listener: callback });
98
+ // return a subscription that we can unsubscribe
99
+ return {
100
+ unsubscribe: () => this.unsubscribe(eventNameByConvention, callback)
101
+ };
54
102
  }
55
103
  /**
56
104
  * Subscribes to a custom event message channel or message type.
@@ -63,60 +111,55 @@ class EventPubSubService {
63
111
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
64
112
  this._elementSource.addEventListener(eventNameByConvention, listener);
65
113
  this._subscribedEvents.push({ name: eventNameByConvention, listener });
114
+ // return a subscription that we can unsubscribe
115
+ return {
116
+ unsubscribe: () => this.unsubscribe(eventNameByConvention, listener)
117
+ };
66
118
  }
67
119
  /**
68
120
  * Unsubscribes a message name
69
- * @param event The event name
121
+ * @param {String} event - the event name
122
+ * @param {*} listener - event listener callback
123
+ * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
70
124
  * @return possibly a Subscription
71
125
  */
72
- unsubscribe(eventName, listener) {
126
+ unsubscribe(eventName, listener, shouldRemoveFromEventList = true) {
73
127
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
74
128
  this._elementSource.removeEventListener(eventNameByConvention, listener);
129
+ if (shouldRemoveFromEventList) {
130
+ this.removeSubscribedEventWhenFound(eventName, listener);
131
+ }
75
132
  }
76
- /** Unsubscribes all subscriptions that currently exists */
133
+ /** Unsubscribes all subscriptions/events that currently exists */
77
134
  unsubscribeAll(subscriptions) {
78
135
  if (Array.isArray(subscriptions)) {
79
- for (const subscription of subscriptions) {
136
+ let subscription;
137
+ do {
138
+ subscription = subscriptions.pop();
80
139
  if (subscription === null || subscription === void 0 ? void 0 : subscription.dispose) {
81
140
  subscription.dispose();
82
141
  }
83
142
  else if (subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe) {
84
143
  subscription.unsubscribe();
85
144
  }
86
- }
145
+ } while (subscription);
87
146
  }
88
147
  else {
89
- for (const pubSubEvent of this._subscribedEvents) {
90
- this.unsubscribe(pubSubEvent.name, pubSubEvent.listener);
148
+ let pubSubEvent = this._subscribedEvents.pop();
149
+ while (pubSubEvent) {
150
+ this.unsubscribe(pubSubEvent.name, pubSubEvent.listener, false);
151
+ pubSubEvent = this._subscribedEvents.pop();
91
152
  }
92
153
  }
93
154
  }
94
- /** Dispatch of Custom Event, which by default will bubble up & is cancelable */
95
- dispatchCustomEvent(eventName, data, isBubbling = true, isCancelable = true) {
96
- const eventInit = { bubbles: isBubbling, cancelable: isCancelable };
97
- if (data) {
98
- eventInit.detail = data;
99
- }
100
- return this._elementSource.dispatchEvent(new CustomEvent(eventName, eventInit));
101
- }
102
- /** Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case */
103
- getEventNameByNamingConvention(inputEventName, eventNamePrefix) {
104
- let outputEventName = '';
105
- switch (this.eventNamingStyle) {
106
- case common_1.EventNamingStyle.camelCase:
107
- outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${(0, common_1.titleCase)(inputEventName)}` : inputEventName;
108
- break;
109
- case common_1.EventNamingStyle.kebabCase:
110
- outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${(0, common_1.toKebabCase)(inputEventName)}` : (0, common_1.toKebabCase)(inputEventName);
111
- break;
112
- case common_1.EventNamingStyle.lowerCase:
113
- outputEventName = `${eventNamePrefix}${inputEventName}`.toLowerCase();
114
- break;
115
- case common_1.EventNamingStyle.lowerCaseWithoutOnPrefix:
116
- outputEventName = `${eventNamePrefix}${inputEventName.replace(/^on/, '')}`.toLowerCase();
117
- break;
155
+ // --
156
+ // protected functions
157
+ // --------------------
158
+ removeSubscribedEventWhenFound(eventName, listener) {
159
+ const eventIdx = this._subscribedEvents.findIndex(evt => evt.name === eventName && evt.listener === listener);
160
+ if (eventIdx >= 0) {
161
+ this._subscribedEvents.splice(eventIdx, 1);
118
162
  }
119
- return outputEventName;
120
163
  }
121
164
  }
122
165
  exports.EventPubSubService = EventPubSubService;
@@ -1 +1 @@
1
- {"version":3,"file":"eventPubSub.service.js","sourceRoot":"","sources":["../../src/eventPubSub.service.ts"],"names":[],"mappings":";;;AAAA,wDAAyH;AAOzH,MAAa,kBAAkB;IAc7B,YAAY,aAAuB;QAZzB,sBAAiB,GAAkB,EAAE,CAAC;QAEhD,qBAAgB,GAAG,yBAAgB,CAAC,SAAS,CAAC;QAW5C,2BAA2B;QAC3B,6GAA6G;QAC7G,IAAI,CAAC,cAAc,GAAG,aAAa,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,C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;IACH,CAAC;CACF;AAhLD,gDAgLC"}
@@ -1,15 +1,33 @@
1
- import { EventNamingStyle, EventSubscription, PubSubService } from '@slickgrid-universal/common';
2
- interface PubSubEvent {
1
+ import { EventNamingStyle, EventSubscription, PubSubService, Subscription } from '@slickgrid-universal/common';
2
+ export interface PubSubEvent<T = any> {
3
3
  name: string;
4
- listener: (event: CustomEventInit) => void;
4
+ listener: (event: T | CustomEventInit<T>) => void;
5
5
  }
6
6
  export declare class EventPubSubService implements PubSubService {
7
7
  protected _elementSource: Element;
8
8
  protected _subscribedEvents: PubSubEvent[];
9
9
  eventNamingStyle: EventNamingStyle;
10
+ get elementSource(): Element;
11
+ set elementSource(element: Element);
10
12
  get subscribedEvents(): PubSubEvent[];
11
13
  get subscribedEventNames(): string[];
12
14
  constructor(elementSource?: Element);
15
+ /**
16
+ * Dispatch of Custom Event, which by default will bubble up & is cancelable
17
+ * @param {String} eventName - event name to dispatch
18
+ * @param {*} data - optional data to include in the dispatching
19
+ * @param {Boolean} isBubbling - is the event bubbling up?
20
+ * @param {Boolean} isCancelable - is the event cancellable?
21
+ * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
22
+ */
23
+ dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
24
+ /**
25
+ * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
26
+ * @param {String} inputEventName - name of the event
27
+ * @param {String} eventNamePrefix - prefix to use in the event name
28
+ * @returns {String} - output event name
29
+ */
30
+ getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
13
31
  /**
14
32
  * Method to publish a message via a dispatchEvent.
15
33
  * Return is a Boolean (from the event dispatch) unless a delay is provided if so we'll return the dispatched event in a Promise with a delayed cycle
@@ -28,7 +46,7 @@ export declare class EventPubSubService implements PubSubService {
28
46
  * @param callback The callback to be invoked when the specified message is published.
29
47
  * @return possibly a Subscription
30
48
  */
31
- subscribe<T = any>(eventName: string, callback: (data: any) => void): any;
49
+ subscribe<T = any>(eventName: string, callback: (data: T) => void): Subscription;
32
50
  /**
33
51
  * Subscribes to a custom event message channel or message type.
34
52
  * This is similar to the "subscribe" except that the callback receives an event typed as CustomEventInit and the data will be inside its "event.detail"
@@ -36,18 +54,16 @@ export declare class EventPubSubService implements PubSubService {
36
54
  * @param callback The callback to be invoked when the specified message is published.
37
55
  * @return possibly a Subscription
38
56
  */
39
- subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): any | void;
57
+ subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): Subscription;
40
58
  /**
41
59
  * Unsubscribes a message name
42
- * @param event The event name
60
+ * @param {String} event - the event name
61
+ * @param {*} listener - event listener callback
62
+ * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
43
63
  * @return possibly a Subscription
44
64
  */
45
- unsubscribe(eventName: string, listener: (event: CustomEventInit) => void): void;
46
- /** Unsubscribes all subscriptions that currently exists */
65
+ unsubscribe<T = any>(eventName: string, listener: (event: T | CustomEventInit<T>) => void, shouldRemoveFromEventList?: boolean): void;
66
+ /** Unsubscribes all subscriptions/events that currently exists */
47
67
  unsubscribeAll(subscriptions?: EventSubscription[]): void;
48
- /** Dispatch of Custom Event, which by default will bubble up & is cancelable */
49
- dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
50
- /** Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case */
51
- getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
68
+ protected removeSubscribedEventWhenFound<T>(eventName: string, listener: (event: T | CustomEventInit<T>) => void): void;
52
69
  }
53
- export {};
@@ -7,12 +7,57 @@ export class EventPubSubService {
7
7
  // or create a "phantom DOM node" (a div element that is never rendered) to set up a custom event dispatching
8
8
  this._elementSource = elementSource || document.createElement('div');
9
9
  }
10
+ get elementSource() {
11
+ return this._elementSource;
12
+ }
13
+ set elementSource(element) {
14
+ this._elementSource = element;
15
+ }
10
16
  get subscribedEvents() {
11
17
  return this._subscribedEvents;
12
18
  }
13
19
  get subscribedEventNames() {
14
20
  return this._subscribedEvents.map((pubSubEvent) => pubSubEvent.name);
15
21
  }
22
+ /**
23
+ * Dispatch of Custom Event, which by default will bubble up & is cancelable
24
+ * @param {String} eventName - event name to dispatch
25
+ * @param {*} data - optional data to include in the dispatching
26
+ * @param {Boolean} isBubbling - is the event bubbling up?
27
+ * @param {Boolean} isCancelable - is the event cancellable?
28
+ * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
29
+ */
30
+ dispatchCustomEvent(eventName, data, isBubbling = true, isCancelable = true) {
31
+ const eventInit = { bubbles: isBubbling, cancelable: isCancelable };
32
+ if (data) {
33
+ eventInit.detail = data;
34
+ }
35
+ return this._elementSource.dispatchEvent(new CustomEvent(eventName, eventInit));
36
+ }
37
+ /**
38
+ * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
39
+ * @param {String} inputEventName - name of the event
40
+ * @param {String} eventNamePrefix - prefix to use in the event name
41
+ * @returns {String} - output event name
42
+ */
43
+ getEventNameByNamingConvention(inputEventName, eventNamePrefix) {
44
+ let outputEventName = '';
45
+ switch (this.eventNamingStyle) {
46
+ case EventNamingStyle.camelCase:
47
+ outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${titleCase(inputEventName)}` : inputEventName;
48
+ break;
49
+ case EventNamingStyle.kebabCase:
50
+ outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${toKebabCase(inputEventName)}` : toKebabCase(inputEventName);
51
+ break;
52
+ case EventNamingStyle.lowerCase:
53
+ outputEventName = `${eventNamePrefix}${inputEventName}`.toLowerCase();
54
+ break;
55
+ case EventNamingStyle.lowerCaseWithoutOnPrefix:
56
+ outputEventName = `${eventNamePrefix}${inputEventName.replace(/^on/, '')}`.toLowerCase();
57
+ break;
58
+ }
59
+ return outputEventName;
60
+ }
16
61
  /**
17
62
  * Method to publish a message via a dispatchEvent.
18
63
  * Return is a Boolean (from the event dispatch) unless a delay is provided if so we'll return the dispatched event in a Promise with a delayed cycle
@@ -28,8 +73,7 @@ export class EventPubSubService {
28
73
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
29
74
  if (delay) {
30
75
  return new Promise(resolve => {
31
- const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, true);
32
- setTimeout(() => resolve(isDispatched), delay);
76
+ setTimeout(() => resolve(this.dispatchCustomEvent(eventNameByConvention, data, true, true)), delay);
33
77
  });
34
78
  }
35
79
  else {
@@ -48,6 +92,10 @@ export class EventPubSubService {
48
92
  // basically we substitute the "data" with "event.detail" so that the user ends up with only the "data" result
49
93
  this._elementSource.addEventListener(eventNameByConvention, (event) => callback.call(null, event.detail));
50
94
  this._subscribedEvents.push({ name: eventNameByConvention, listener: callback });
95
+ // return a subscription that we can unsubscribe
96
+ return {
97
+ unsubscribe: () => this.unsubscribe(eventNameByConvention, callback)
98
+ };
51
99
  }
52
100
  /**
53
101
  * Subscribes to a custom event message channel or message type.
@@ -60,60 +108,55 @@ export class EventPubSubService {
60
108
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
61
109
  this._elementSource.addEventListener(eventNameByConvention, listener);
62
110
  this._subscribedEvents.push({ name: eventNameByConvention, listener });
111
+ // return a subscription that we can unsubscribe
112
+ return {
113
+ unsubscribe: () => this.unsubscribe(eventNameByConvention, listener)
114
+ };
63
115
  }
64
116
  /**
65
117
  * Unsubscribes a message name
66
- * @param event The event name
118
+ * @param {String} event - the event name
119
+ * @param {*} listener - event listener callback
120
+ * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
67
121
  * @return possibly a Subscription
68
122
  */
69
- unsubscribe(eventName, listener) {
123
+ unsubscribe(eventName, listener, shouldRemoveFromEventList = true) {
70
124
  const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
71
125
  this._elementSource.removeEventListener(eventNameByConvention, listener);
126
+ if (shouldRemoveFromEventList) {
127
+ this.removeSubscribedEventWhenFound(eventName, listener);
128
+ }
72
129
  }
73
- /** Unsubscribes all subscriptions that currently exists */
130
+ /** Unsubscribes all subscriptions/events that currently exists */
74
131
  unsubscribeAll(subscriptions) {
75
132
  if (Array.isArray(subscriptions)) {
76
- for (const subscription of subscriptions) {
133
+ let subscription;
134
+ do {
135
+ subscription = subscriptions.pop();
77
136
  if (subscription === null || subscription === void 0 ? void 0 : subscription.dispose) {
78
137
  subscription.dispose();
79
138
  }
80
139
  else if (subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe) {
81
140
  subscription.unsubscribe();
82
141
  }
83
- }
142
+ } while (subscription);
84
143
  }
85
144
  else {
86
- for (const pubSubEvent of this._subscribedEvents) {
87
- this.unsubscribe(pubSubEvent.name, pubSubEvent.listener);
145
+ let pubSubEvent = this._subscribedEvents.pop();
146
+ while (pubSubEvent) {
147
+ this.unsubscribe(pubSubEvent.name, pubSubEvent.listener, false);
148
+ pubSubEvent = this._subscribedEvents.pop();
88
149
  }
89
150
  }
90
151
  }
91
- /** Dispatch of Custom Event, which by default will bubble up & is cancelable */
92
- dispatchCustomEvent(eventName, data, isBubbling = true, isCancelable = true) {
93
- const eventInit = { bubbles: isBubbling, cancelable: isCancelable };
94
- if (data) {
95
- eventInit.detail = data;
96
- }
97
- return this._elementSource.dispatchEvent(new CustomEvent(eventName, eventInit));
98
- }
99
- /** Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case */
100
- getEventNameByNamingConvention(inputEventName, eventNamePrefix) {
101
- let outputEventName = '';
102
- switch (this.eventNamingStyle) {
103
- case EventNamingStyle.camelCase:
104
- outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${titleCase(inputEventName)}` : inputEventName;
105
- break;
106
- case EventNamingStyle.kebabCase:
107
- outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${toKebabCase(inputEventName)}` : toKebabCase(inputEventName);
108
- break;
109
- case EventNamingStyle.lowerCase:
110
- outputEventName = `${eventNamePrefix}${inputEventName}`.toLowerCase();
111
- break;
112
- case EventNamingStyle.lowerCaseWithoutOnPrefix:
113
- outputEventName = `${eventNamePrefix}${inputEventName.replace(/^on/, '')}`.toLowerCase();
114
- break;
152
+ // --
153
+ // protected functions
154
+ // --------------------
155
+ removeSubscribedEventWhenFound(eventName, listener) {
156
+ const eventIdx = this._subscribedEvents.findIndex(evt => evt.name === eventName && evt.listener === listener);
157
+ if (eventIdx >= 0) {
158
+ this._subscribedEvents.splice(eventIdx, 1);
115
159
  }
116
- return outputEventName;
117
160
  }
118
161
  }
119
162
  //# sourceMappingURL=eventPubSub.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eventPubSub.service.js","sourceRoot":"","sources":["../../src/eventPubSub.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoC,SAAS,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAOzH,MAAM,OAAO,kBAAkB;IAc7B,YAAY,aAAuB;QAZzB,sBAAiB,GAAkB,EAAE,CAAC;QAEhD,qBAAgB,GAAG,gBAAgB,CAAC,SAAS,CAAC;QAW5C,2BAA2B;QAC3B,6GAA6G;QAC7G,IAAI,CAAC,cAAc,GAAG,aAAa,IAAI,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IAZD,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAI,oBAAoB;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACvE,CAAC;IAQD;;;;;;;;;;OAUG;IACH,OAAO,CAAU,SAAiB,EAAE,IAAQ,EAAE,KAAc;QAC1D,MAAM,qBAAqB,GAAG,IAAI,CAAC,8BAA8B,CAAC,SAAS,EAA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BAAZ,YAAY,CAAE,OAAO,EAAE;oBACzB,YAAY,CAAC,OAAO,EAAE,CAAC;iBACxB;qBAAM,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,WAAW,EAAE;oBACpC,YAAY,CAAC,WAAW,EAAE,CAAC;iBAC5B;aACF,QAAQ,YAAY,EAAE;SACxB;aAAM;YACL,IAAI,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;YAC/C,OAAO,WAAW,EAAE;gBAClB,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;gBAChE,WAAW,GAAG,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;aAC5C;SACF;IACH,CAAC;IAED,KAAK;IACL,sBAAsB;IACtB,uBAAuB;IAEb,8BAA8B,CAAI,SAAiB,EAAE,QAAiD;QAC9G,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;QAC9G,IAAI,QAAQ,IAAI,CAAC,EAAE;YACjB,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;SAC5C;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slickgrid-universal/event-pub-sub",
3
- "version": "0.19.1",
3
+ "version": "1.2.0",
4
4
  "description": "Simple Vanilla Implementation of an Event PubSub Service to do simply publish/subscribe inter-communication while optionally providing data in the event",
5
5
  "main": "dist/commonjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -47,12 +47,12 @@
47
47
  "not dead"
48
48
  ],
49
49
  "dependencies": {
50
- "@slickgrid-universal/common": "^0.19.1"
50
+ "@slickgrid-universal/common": "^1.2.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "cross-env": "^7.0.3",
54
54
  "npm-run-all": "^4.1.5",
55
55
  "rimraf": "^3.0.2"
56
56
  },
57
- "gitHead": "073f79eabe7762c02c15fd79b603bf7bcc4e2f71"
57
+ "gitHead": "af25eecf8994d5b6ec9eb13bfd266cba71c1cfcb"
58
58
  }