New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@slickgrid-universal/event-pub-sub

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slickgrid-universal/event-pub-sub - npm Package Compare versions

Comparing version 0.16.2 to 0.17.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [0.17.0](https://github.com/ghiscoding/slickgrid-universal/compare/v0.16.2...v0.17.0) (2021-09-09)
### Features
* **backend:** add cancellable onBeforeSearchChange & revert on error ([b26a53d](https://github.com/ghiscoding/slickgrid-universal/commit/b26a53d2e1fc7172c8c054b9c27ab1b3a2d3dff6))
## [0.16.2](https://github.com/ghiscoding/slickgrid-universal/compare/v0.16.1...v0.16.2) (2021-07-23)

@@ -8,0 +19,0 @@

15

dist/commonjs/eventPubSub.service.d.ts

@@ -15,9 +15,12 @@ import { EventNamingStyle, EventSubscription, PubSubService } from '@slickgrid-universal/common';

* Method to publish a message via a dispatchEvent.
* We return the dispatched event in a Promise with a delayed cycle and we do this because
* most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for these events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param event The event or channel to publish to.
* @param data The data to publish on the channel.
* 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
* The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
* and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param {String} event - The event or channel to publish to.
* @param {*} data - The data to publish on the channel.
* @param {Number} delay - optional argument to delay the publish event
* @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
*/
publish<T = any>(eventName: string, data?: T): Promise<boolean>;
publish<T = any>(eventName: string, data?: T, delay?: number): boolean | Promise<boolean>;
/**

@@ -24,0 +27,0 @@ * Subscribes to a message channel or message type.

32

dist/commonjs/eventPubSub.service.js

@@ -21,14 +21,22 @@ "use strict";

* Method to publish a message via a dispatchEvent.
* We return the dispatched event in a Promise with a delayed cycle and we do this because
* most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for these events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param event The event or channel to publish to.
* @param data The data to publish on the channel.
* 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
* The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
* and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param {String} event - The event or channel to publish to.
* @param {*} data - The data to publish on the channel.
* @param {Number} delay - optional argument to delay the publish event
* @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
*/
publish(eventName, data) {
publish(eventName, data, delay) {
const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
return new Promise(resolve => {
const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, false);
setTimeout(() => resolve(isDispatched), 0);
});
if (delay) {
return new Promise(resolve => {
const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, true);
setTimeout(() => resolve(isDispatched), delay);
});
}
else {
return this.dispatchCustomEvent(eventNameByConvention, data, true, true);
}
}

@@ -100,6 +108,6 @@ /**

case common_1.EventNamingStyle.camelCase:
outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${common_1.titleCase(inputEventName)}` : inputEventName;
outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}${(0, common_1.titleCase)(inputEventName)}` : inputEventName;
break;
case common_1.EventNamingStyle.kebabCase:
outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${common_1.toKebabCase(inputEventName)}` : common_1.toKebabCase(inputEventName);
outputEventName = (eventNamePrefix !== '') ? `${eventNamePrefix}-${(0, common_1.toKebabCase)(inputEventName)}` : (0, common_1.toKebabCase)(inputEventName);
break;

@@ -106,0 +114,0 @@ case common_1.EventNamingStyle.lowerCase:

@@ -15,9 +15,12 @@ import { EventNamingStyle, EventSubscription, PubSubService } from '@slickgrid-universal/common';

* Method to publish a message via a dispatchEvent.
* We return the dispatched event in a Promise with a delayed cycle and we do this because
* most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for these events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param event The event or channel to publish to.
* @param data The data to publish on the channel.
* 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
* The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
* and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param {String} event - The event or channel to publish to.
* @param {*} data - The data to publish on the channel.
* @param {Number} delay - optional argument to delay the publish event
* @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
*/
publish<T = any>(eventName: string, data?: T): Promise<boolean>;
publish<T = any>(eventName: string, data?: T, delay?: number): boolean | Promise<boolean>;
/**

@@ -24,0 +27,0 @@ * Subscribes to a message channel or message type.

@@ -18,14 +18,22 @@ import { EventNamingStyle, titleCase, toKebabCase } from '@slickgrid-universal/common';

* Method to publish a message via a dispatchEvent.
* We return the dispatched event in a Promise with a delayed cycle and we do this because
* most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for these events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param event The event or channel to publish to.
* @param data The data to publish on the channel.
* 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
* The delay is rarely use and is only used when we want to make sure that certain events have the time to execute
* and we do this because most framework require a cycle before the binding is processed and binding a spinner end up showing too late
* for example this is used for the following events: onBeforeFilterClear, onBeforeFilterChange, onBeforeToggleTreeCollapse, onBeforeSortChange
* @param {String} event - The event or channel to publish to.
* @param {*} data - The data to publish on the channel.
* @param {Number} delay - optional argument to delay the publish event
* @returns {Boolean | Promise} - return type will be a Boolean unless a `delay` is provided then a `Promise<Boolean>` will be returned
*/
publish(eventName, data) {
publish(eventName, data, delay) {
const eventNameByConvention = this.getEventNameByNamingConvention(eventName, '');
return new Promise(resolve => {
const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, false);
setTimeout(() => resolve(isDispatched), 0);
});
if (delay) {
return new Promise(resolve => {
const isDispatched = this.dispatchCustomEvent(eventNameByConvention, data, true, true);
setTimeout(() => resolve(isDispatched), delay);
});
}
else {
return this.dispatchCustomEvent(eventNameByConvention, data, true, true);
}
}

@@ -32,0 +40,0 @@ /**

{
"name": "@slickgrid-universal/event-pub-sub",
"version": "0.16.2",
"version": "0.17.0",
"description": "Simple Vanilla Implementation of an Event PubSub Service to do simply publish/subscribe inter-communication while optionally providing data in the event",

@@ -41,3 +41,3 @@ "main": "dist/commonjs/index.js",

"dependencies": {
"@slickgrid-universal/common": "^0.16.2"
"@slickgrid-universal/common": "^0.17.0"
},

@@ -49,3 +49,3 @@ "devDependencies": {

},
"gitHead": "3ca88953c78f66ead14a1e4f26d9c7b7a2625b79"
"gitHead": "13dfd69e953b298a1412892044fbf1c4c713c131"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc