@slickgrid-universal/event-pub-sub 2.4.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.
- package/dist/commonjs/basePubSub.service.js +47 -47
- package/dist/commonjs/eventPubSub.service.js +175 -175
- package/dist/commonjs/index.js +19 -19
- package/dist/commonjs/types/eventNamingStyle.enum.js +14 -14
- package/dist/commonjs/types/eventSubscription.interface.js +2 -2
- package/dist/commonjs/types/index.js +18 -18
- package/dist/esm/basePubSub.service.js +43 -43
- package/dist/esm/eventPubSub.service.js +171 -171
- package/dist/esm/index.js +3 -3
- package/dist/esm/types/eventNamingStyle.enum.js +11 -11
- package/dist/esm/types/eventSubscription.interface.js +1 -1
- package/dist/esm/types/index.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/{commonjs → types}/basePubSub.service.d.ts +33 -32
- package/dist/types/basePubSub.service.d.ts.map +1 -0
- package/dist/{esm → types}/eventPubSub.service.d.ts +73 -72
- package/dist/types/eventPubSub.service.d.ts.map +1 -0
- package/dist/{esm → types}/index.d.ts +4 -3
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{esm → types}/types/eventNamingStyle.enum.d.ts +11 -10
- package/dist/types/types/eventNamingStyle.enum.d.ts.map +1 -0
- package/dist/{commonjs → types}/types/eventSubscription.interface.d.ts +11 -10
- package/dist/types/types/eventSubscription.interface.d.ts.map +1 -0
- package/dist/{commonjs → types}/types/index.d.ts +3 -2
- package/dist/types/types/index.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/commonjs/eventPubSub.service.d.ts +0 -72
- package/dist/commonjs/index.d.ts +0 -3
- package/dist/commonjs/types/eventNamingStyle.enum.d.ts +0 -10
- package/dist/esm/basePubSub.service.d.ts +0 -32
- package/dist/esm/types/eventSubscription.interface.d.ts +0 -10
- 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.
|
|
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
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"import": "./dist/esm/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/
|
|
18
|
+
"./dist/types/index.d.ts"
|
|
19
19
|
]
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"types": "dist/
|
|
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.
|
|
46
|
+
"@slickgrid-universal/utils": "~2.6.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
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
|
-
}
|
package/dist/commonjs/index.d.ts
DELETED
|
@@ -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
|
-
}
|