@slickgrid-universal/event-pub-sub 2.5.0 → 2.6.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.
Files changed (32) hide show
  1. package/dist/commonjs/basePubSub.service.js +47 -47
  2. package/dist/commonjs/eventPubSub.service.js +175 -175
  3. package/dist/commonjs/index.js +19 -19
  4. package/dist/commonjs/types/eventNamingStyle.enum.js +14 -14
  5. package/dist/commonjs/types/eventSubscription.interface.js +2 -2
  6. package/dist/commonjs/types/index.js +18 -18
  7. package/dist/esm/basePubSub.service.js +43 -43
  8. package/dist/esm/eventPubSub.service.js +171 -171
  9. package/dist/esm/index.js +3 -3
  10. package/dist/esm/types/eventNamingStyle.enum.js +11 -11
  11. package/dist/esm/types/eventSubscription.interface.js +1 -1
  12. package/dist/esm/types/index.js +2 -2
  13. package/dist/tsconfig.tsbuildinfo +1 -0
  14. package/dist/{commonjs → types}/basePubSub.service.d.ts +33 -32
  15. package/dist/types/basePubSub.service.d.ts.map +1 -0
  16. package/dist/{esm → types}/eventPubSub.service.d.ts +73 -72
  17. package/dist/types/eventPubSub.service.d.ts.map +1 -0
  18. package/dist/{esm → types}/index.d.ts +4 -3
  19. package/dist/types/index.d.ts.map +1 -0
  20. package/dist/{esm → types}/types/eventNamingStyle.enum.d.ts +11 -10
  21. package/dist/types/types/eventNamingStyle.enum.d.ts.map +1 -0
  22. package/dist/{commonjs → types}/types/eventSubscription.interface.d.ts +11 -10
  23. package/dist/types/types/eventSubscription.interface.d.ts.map +1 -0
  24. package/dist/{commonjs → types}/types/index.d.ts +3 -2
  25. package/dist/types/types/index.d.ts.map +1 -0
  26. package/package.json +7 -7
  27. package/dist/commonjs/eventPubSub.service.d.ts +0 -72
  28. package/dist/commonjs/index.d.ts +0 -3
  29. package/dist/commonjs/types/eventNamingStyle.enum.d.ts +0 -10
  30. package/dist/esm/basePubSub.service.d.ts +0 -32
  31. package/dist/esm/types/eventSubscription.interface.d.ts +0 -10
  32. package/dist/esm/types/index.d.ts +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"basePubSub.service.d.ts","sourceRoot":"","sources":["../../src/basePubSub.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C,8BAAsB,iBAAiB;IACrC;;;;OAIG;IACH,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAIzG;;;;;QAKI;IAEJ,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,iBAAiB,GAAG,GAAG;IAIxG;;;;;;QAMI;IAEJ,cAAc,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,QAAQ,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,iBAAiB,GAAG,GAAG;IAIhI;;;;QAII;IACJ,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI;IAIlF,2DAA2D;IAC3D,cAAc,CAAC,cAAc,CAAC,EAAE,iBAAiB,EAAE,GAAG,IAAI;CAG3D"}
@@ -1,72 +1,73 @@
1
- import { BasePubSubService } from './basePubSub.service';
2
- import { EventNamingStyle, EventSubscription, Subscription } from './types';
3
- export interface PubSubEvent<T = any> {
4
- name: string;
5
- listener: (event: T | CustomEventInit<T>) => void;
6
- }
7
- export declare class EventPubSubService implements BasePubSubService {
8
- protected _elementSource: Element;
9
- protected _subscribedEvents: PubSubEvent[];
10
- protected _timer: any;
11
- eventNamingStyle: EventNamingStyle;
12
- get elementSource(): Element;
13
- set elementSource(element: Element);
14
- get subscribedEvents(): PubSubEvent[];
15
- get subscribedEventNames(): string[];
16
- constructor(elementSource?: Element);
17
- dispose(): void;
18
- /**
19
- * Dispatch of Custom Event, which by default will bubble up & is cancelable
20
- * @param {String} eventName - event name to dispatch
21
- * @param {*} data - optional data to include in the dispatching
22
- * @param {Boolean} isBubbling - is the event bubbling up?
23
- * @param {Boolean} isCancelable - is the event cancellable?
24
- * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
25
- */
26
- dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
27
- /**
28
- * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
29
- * @param {String} inputEventName - name of the event
30
- * @param {String} eventNamePrefix - prefix to use in the event name
31
- * @returns {String} - output event name
32
- */
33
- getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
34
- /**
35
- * Method to publish a message via a dispatchEvent.
36
- * 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
37
- * The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
38
- * and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
39
- * for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
40
- * @param {String} event - The event or channel to publish to.
41
- * @param {*} data - The data to publish on the channel.
42
- * @param {Number} delay - optional argument to delay the publish event
43
- * @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
44
- */
45
- publish<T = any>(eventName: string, data?: T, delay?: number): boolean | Promise<boolean>;
46
- /**
47
- * Subscribes to a message channel or message type.
48
- * @param event The event channel or event data type.
49
- * @param callback The callback to be invoked when the specified message is published.
50
- * @return possibly a Subscription
51
- */
52
- subscribe<T = any>(eventName: string, callback: (data: T) => void): Subscription;
53
- /**
54
- * Subscribes to a custom event message channel or message type.
55
- * 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"
56
- * @param event The event channel or event data type.
57
- * @param callback The callback to be invoked when the specified message is published.
58
- * @return possibly a Subscription
59
- */
60
- subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): Subscription;
61
- /**
62
- * Unsubscribes a message name
63
- * @param {String} event - the event name
64
- * @param {*} listener - event listener callback
65
- * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
66
- * @return possibly a Subscription
67
- */
68
- unsubscribe<T = any>(eventName: string, listener: (event: T | CustomEventInit<T>) => void, shouldRemoveFromEventList?: boolean): void;
69
- /** Unsubscribes all subscriptions/events that currently exists */
70
- unsubscribeAll(subscriptions?: EventSubscription[]): void;
71
- protected removeSubscribedEventWhenFound<T>(eventName: string, listener: (event: T | CustomEventInit<T>) => void): void;
72
- }
1
+ import { BasePubSubService } from './basePubSub.service';
2
+ import { EventNamingStyle, EventSubscription, Subscription } from './types';
3
+ export interface PubSubEvent<T = any> {
4
+ name: string;
5
+ listener: (event: T | CustomEventInit<T>) => void;
6
+ }
7
+ export declare class EventPubSubService implements BasePubSubService {
8
+ protected _elementSource: Element;
9
+ protected _subscribedEvents: PubSubEvent[];
10
+ protected _timer: any;
11
+ eventNamingStyle: EventNamingStyle;
12
+ get elementSource(): Element;
13
+ set elementSource(element: Element);
14
+ get subscribedEvents(): PubSubEvent[];
15
+ get subscribedEventNames(): string[];
16
+ constructor(elementSource?: Element);
17
+ dispose(): void;
18
+ /**
19
+ * Dispatch of Custom Event, which by default will bubble up & is cancelable
20
+ * @param {String} eventName - event name to dispatch
21
+ * @param {*} data - optional data to include in the dispatching
22
+ * @param {Boolean} isBubbling - is the event bubbling up?
23
+ * @param {Boolean} isCancelable - is the event cancellable?
24
+ * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
25
+ */
26
+ dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
27
+ /**
28
+ * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
29
+ * @param {String} inputEventName - name of the event
30
+ * @param {String} eventNamePrefix - prefix to use in the event name
31
+ * @returns {String} - output event name
32
+ */
33
+ getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
34
+ /**
35
+ * Method to publish a message via a dispatchEvent.
36
+ * 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
37
+ * The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
38
+ * and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
39
+ * for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
40
+ * @param {String} event - The event or channel to publish to.
41
+ * @param {*} data - The data to publish on the channel.
42
+ * @param {Number} delay - optional argument to delay the publish event
43
+ * @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
44
+ */
45
+ publish<T = any>(eventName: string, data?: T, delay?: number): boolean | Promise<boolean>;
46
+ /**
47
+ * Subscribes to a message channel or message type.
48
+ * @param event The event channel or event data type.
49
+ * @param callback The callback to be invoked when the specified message is published.
50
+ * @return possibly a Subscription
51
+ */
52
+ subscribe<T = any>(eventName: string, callback: (data: T) => void): Subscription;
53
+ /**
54
+ * Subscribes to a custom event message channel or message type.
55
+ * 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"
56
+ * @param event The event channel or event data type.
57
+ * @param callback The callback to be invoked when the specified message is published.
58
+ * @return possibly a Subscription
59
+ */
60
+ subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): Subscription;
61
+ /**
62
+ * Unsubscribes a message name
63
+ * @param {String} event - the event name
64
+ * @param {*} listener - event listener callback
65
+ * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
66
+ * @return possibly a Subscription
67
+ */
68
+ unsubscribe<T = any>(eventName: string, listener: (event: T | CustomEventInit<T>) => void, shouldRemoveFromEventList?: boolean): void;
69
+ /** Unsubscribes all subscriptions/events that currently exists */
70
+ unsubscribeAll(subscriptions?: EventSubscription[]): void;
71
+ protected removeSubscribedEventWhenFound<T>(eventName: string, listener: (event: T | CustomEventInit<T>) => void): void;
72
+ }
73
+ //# sourceMappingURL=eventPubSub.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventPubSub.service.d.ts","sourceRoot":"","sources":["../../src/eventPubSub.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,YAAY,EAAG,MAAM,SAAS,CAAC;AAE7E,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CACnD;AAED,qBAAa,kBAAmB,YAAW,iBAAiB;IAC1D,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC;IAClC,SAAS,CAAC,iBAAiB,EAAE,WAAW,EAAE,CAAM;IAChD,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;IAEtB,gBAAgB,mBAA8B;IAE9C,IAAI,aAAa,IAGU,OAAO,CADjC;IACD,IAAI,aAAa,CAAC,OAAO,EAAE,OAAO,EAEjC;IAED,IAAI,gBAAgB,IAAI,WAAW,EAAE,CAEpC;IAED,IAAI,oBAAoB,IAAI,MAAM,EAAE,CAEnC;gBAEW,aAAa,CAAC,EAAE,OAAO;IAMnC,OAAO;IAQP;;;;;;;OAOG;IACH,mBAAmB,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,UAAU,UAAO,EAAE,YAAY,UAAO;IAQhG;;;;;OAKG;IACH,8BAA8B,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM;IAoB9E;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAYzF;;;;;OAKG;IACH,SAAS,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,YAAY;IAchF;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,YAAY;IAWvG;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,yBAAyB,UAAO;IAQ3H,kEAAkE;IAClE,cAAc,CAAC,aAAa,CAAC,EAAE,iBAAiB,EAAE;IAwBlD,SAAS,CAAC,8BAA8B,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI;CAMjH"}
@@ -1,3 +1,4 @@
1
- export * from './basePubSub.service';
2
- export * from './eventPubSub.service';
3
- export * from './types';
1
+ export * from './basePubSub.service';
2
+ export * from './eventPubSub.service';
3
+ export * from './types';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC"}
@@ -1,10 +1,11 @@
1
- export declare enum EventNamingStyle {
2
- /** Event name showing in Camel Case, so "onValidationError" would stay as "onValidationError" */
3
- camelCase = "camelCase",
4
- /** Event name showing in Kebab Case, so "onValidationError" would become "on-validation-error" */
5
- kebabCase = "kebabCase",
6
- /** Event name showing all in lowercase, so "onValidationError" would become "onvalidationerror" */
7
- lowerCase = "lowerCase",
8
- /** Event name showing all in lowercase but without the "on" prefix, so "onValidationError" would become "validationerror" */
9
- lowerCaseWithoutOnPrefix = "lowerCaseWithoutOnPrefix"
10
- }
1
+ export declare enum EventNamingStyle {
2
+ /** Event name showing in Camel Case, so "onValidationError" would stay as "onValidationError" */
3
+ camelCase = "camelCase",
4
+ /** Event name showing in Kebab Case, so "onValidationError" would become "on-validation-error" */
5
+ kebabCase = "kebabCase",
6
+ /** Event name showing all in lowercase, so "onValidationError" would become "onvalidationerror" */
7
+ lowerCase = "lowerCase",
8
+ /** Event name showing all in lowercase but without the "on" prefix, so "onValidationError" would become "validationerror" */
9
+ lowerCaseWithoutOnPrefix = "lowerCaseWithoutOnPrefix"
10
+ }
11
+ //# sourceMappingURL=eventNamingStyle.enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventNamingStyle.enum.d.ts","sourceRoot":"","sources":["../../../src/types/eventNamingStyle.enum.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,iGAAiG;IACjG,SAAS,cAAc;IAEvB,kGAAkG;IAClG,SAAS,cAAc;IAEvB,mGAAmG;IACnG,SAAS,cAAc;IAEvB,6HAA6H;IAC7H,wBAAwB,6BAA6B;CACtD"}
@@ -1,10 +1,11 @@
1
- export interface EventSubscription {
2
- /** Disposes the subscription. */
3
- dispose?: () => void;
4
- /** Disposes the resources held by the subscription. */
5
- unsubscribe?: () => void;
6
- }
7
- export interface Subscription {
8
- /** Disposes the resources held by the subscription. */
9
- unsubscribe: () => void;
10
- }
1
+ export interface EventSubscription {
2
+ /** Disposes the subscription. */
3
+ dispose?: () => void;
4
+ /** Disposes the resources held by the subscription. */
5
+ unsubscribe?: () => void;
6
+ }
7
+ export interface Subscription {
8
+ /** Disposes the resources held by the subscription. */
9
+ unsubscribe: () => void;
10
+ }
11
+ //# sourceMappingURL=eventSubscription.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventSubscription.interface.d.ts","sourceRoot":"","sources":["../../../src/types/eventSubscription.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,uDAAuD;IACvD,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB"}
@@ -1,2 +1,3 @@
1
- export * from './eventNamingStyle.enum';
2
- export * from './eventSubscription.interface';
1
+ export * from './eventNamingStyle.enum';
2
+ export * from './eventSubscription.interface';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC"}
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@slickgrid-universal/event-pub-sub",
3
- "version": "2.5.0",
3
+ "version": "2.6.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",
7
7
  "exports": {
8
8
  ".": {
9
- "browser": "./dist/esm/index.js",
10
9
  "import": "./dist/esm/index.js",
11
- "require": "./dist/commonjs/index.js"
10
+ "require": "./dist/commonjs/index.js",
11
+ "default": "./dist/esm/index.js"
12
12
  },
13
13
  "./*": "./*"
14
14
  },
15
15
  "typesVersions": {
16
16
  "*": {
17
17
  "*": [
18
- "./dist/esm/index.d.ts"
18
+ "./dist/types/index.d.ts"
19
19
  ]
20
20
  }
21
21
  },
22
- "types": "dist/esm/index.d.ts",
22
+ "types": "dist/types/index.d.ts",
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
@@ -43,7 +43,7 @@
43
43
  "not dead"
44
44
  ],
45
45
  "dependencies": {
46
- "@slickgrid-universal/utils": "~2.5.0"
46
+ "@slickgrid-universal/utils": "~2.6.0"
47
47
  },
48
- "gitHead": "5e25aa044aab301d7246c24003386ab59e75b486"
48
+ "gitHead": "9cddf3ee91a91ca829d0ced99c1f20f6d0e9941f"
49
49
  }
@@ -1,72 +0,0 @@
1
- import { BasePubSubService } from './basePubSub.service';
2
- import { EventNamingStyle, EventSubscription, Subscription } from './types';
3
- export interface PubSubEvent<T = any> {
4
- name: string;
5
- listener: (event: T | CustomEventInit<T>) => void;
6
- }
7
- export declare class EventPubSubService implements BasePubSubService {
8
- protected _elementSource: Element;
9
- protected _subscribedEvents: PubSubEvent[];
10
- protected _timer: any;
11
- eventNamingStyle: EventNamingStyle;
12
- get elementSource(): Element;
13
- set elementSource(element: Element);
14
- get subscribedEvents(): PubSubEvent[];
15
- get subscribedEventNames(): string[];
16
- constructor(elementSource?: Element);
17
- dispose(): void;
18
- /**
19
- * Dispatch of Custom Event, which by default will bubble up & is cancelable
20
- * @param {String} eventName - event name to dispatch
21
- * @param {*} data - optional data to include in the dispatching
22
- * @param {Boolean} isBubbling - is the event bubbling up?
23
- * @param {Boolean} isCancelable - is the event cancellable?
24
- * @returns {Boolean} returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
25
- */
26
- dispatchCustomEvent<T = any>(eventName: string, data?: T, isBubbling?: boolean, isCancelable?: boolean): boolean;
27
- /**
28
- * Get the event name by the convention defined, it could be: all lower case, camelCase, PascalCase or kebab-case
29
- * @param {String} inputEventName - name of the event
30
- * @param {String} eventNamePrefix - prefix to use in the event name
31
- * @returns {String} - output event name
32
- */
33
- getEventNameByNamingConvention(inputEventName: string, eventNamePrefix: string): string;
34
- /**
35
- * Method to publish a message via a dispatchEvent.
36
- * 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
37
- * The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
38
- * and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
39
- * for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
40
- * @param {String} event - The event or channel to publish to.
41
- * @param {*} data - The data to publish on the channel.
42
- * @param {Number} delay - optional argument to delay the publish event
43
- * @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
44
- */
45
- publish<T = any>(eventName: string, data?: T, delay?: number): boolean | Promise<boolean>;
46
- /**
47
- * Subscribes to a message channel or message type.
48
- * @param event The event channel or event data type.
49
- * @param callback The callback to be invoked when the specified message is published.
50
- * @return possibly a Subscription
51
- */
52
- subscribe<T = any>(eventName: string, callback: (data: T) => void): Subscription;
53
- /**
54
- * Subscribes to a custom event message channel or message type.
55
- * 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"
56
- * @param event The event channel or event data type.
57
- * @param callback The callback to be invoked when the specified message is published.
58
- * @return possibly a Subscription
59
- */
60
- subscribeEvent<T = any>(eventName: string, listener: (event: CustomEventInit<T>) => void): Subscription;
61
- /**
62
- * Unsubscribes a message name
63
- * @param {String} event - the event name
64
- * @param {*} listener - event listener callback
65
- * @param {Boolean} shouldRemoveFromEventList - should we also remove the event from the subscriptions array?
66
- * @return possibly a Subscription
67
- */
68
- unsubscribe<T = any>(eventName: string, listener: (event: T | CustomEventInit<T>) => void, shouldRemoveFromEventList?: boolean): void;
69
- /** Unsubscribes all subscriptions/events that currently exists */
70
- unsubscribeAll(subscriptions?: EventSubscription[]): void;
71
- protected removeSubscribedEventWhenFound<T>(eventName: string, listener: (event: T | CustomEventInit<T>) => void): void;
72
- }
@@ -1,3 +0,0 @@
1
- export * from './basePubSub.service';
2
- export * from './eventPubSub.service';
3
- export * from './types';
@@ -1,10 +0,0 @@
1
- export declare enum EventNamingStyle {
2
- /** Event name showing in Camel Case, so "onValidationError" would stay as "onValidationError" */
3
- camelCase = "camelCase",
4
- /** Event name showing in Kebab Case, so "onValidationError" would become "on-validation-error" */
5
- kebabCase = "kebabCase",
6
- /** Event name showing all in lowercase, so "onValidationError" would become "onvalidationerror" */
7
- lowerCase = "lowerCase",
8
- /** Event name showing all in lowercase but without the "on" prefix, so "onValidationError" would become "validationerror" */
9
- lowerCaseWithoutOnPrefix = "lowerCaseWithoutOnPrefix"
10
- }
@@ -1,32 +0,0 @@
1
- import { EventSubscription } from './types';
2
- export declare abstract class BasePubSubService {
3
- /**
4
- * Method to publish a message
5
- * @param event The event or channel to publish to.
6
- * @param data The data to publish on the channel.
7
- */
8
- publish<T = any>(_eventName: string | any, _data?: T, _delay?: number): void | boolean | Promise<boolean>;
9
- /**
10
- * Subscribes to a message channel or message type.
11
- * @param event The event channel or event data type.
12
- * @param callback The callback to be invoked when the specified message is published.
13
- * @return possibly a Subscription
14
- */
15
- subscribe<T = any>(_eventName: string | Function, _callback: (data: T) => void): EventSubscription | any;
16
- /**
17
- * Subscribes to a custom event message channel or message type.
18
- * 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"
19
- * @param event The event channel or event data type.
20
- * @param callback The callback to be invoked when the specified message is published.
21
- * @return possibly a Subscription
22
- */
23
- subscribeEvent?<T = any>(_eventName: string | Function, _callback: (event: CustomEventInit<T>) => void): EventSubscription | any;
24
- /**
25
- * Unsubscribes a message name
26
- * @param event The event name
27
- * @return possibly a Subscription
28
- */
29
- unsubscribe(_eventName: string, _callback: (event: CustomEventInit) => void): void;
30
- /** Unsubscribes all subscriptions that currently exists */
31
- unsubscribeAll(_subscriptions?: EventSubscription[]): void;
32
- }
@@ -1,10 +0,0 @@
1
- export interface EventSubscription {
2
- /** Disposes the subscription. */
3
- dispose?: () => void;
4
- /** Disposes the resources held by the subscription. */
5
- unsubscribe?: () => void;
6
- }
7
- export interface Subscription {
8
- /** Disposes the resources held by the subscription. */
9
- unsubscribe: () => void;
10
- }
@@ -1,2 +0,0 @@
1
- export * from './eventNamingStyle.enum';
2
- export * from './eventSubscription.interface';