Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
NotificationCenter.prototype.clearAllNotificationListeners = function () {
try{
utils.objectValues(enums.NOTIFICATION_TYPES).forEach(function (notificationTypeEnum) {
this.__notificationListeners[notificationTypeEnum] = [];
}.bind(this));
} catch (e) {
this.logger.log(LOG_LEVEL.ERROR, e.message);
this.errorHandler.handleError(e);
}
};
stop(): Promise {
try {
super.stop()
const toSave = objectValues(this.buffer).map(obj => ({
...obj,
status: EntryStatus.QUEUED,
}))
window.localStorage.setItem(LS_KEY, JSON.stringify(toSave))
} catch (e) {
logger.error('Error stopping BrowserDispatchQueue: "%s"', e.message, e)
}
return Promise.resolve()
}
}
values(): K[] {
return objectValues(this.getMap())
}
NotificationCenter.prototype.addNotificationListener = function (notificationType, callback) {
try {
var isNotificationTypeValid = utils.objectValues(enums.NOTIFICATION_TYPES)
.indexOf(notificationType) > -1;
if (!isNotificationTypeValid) {
return -1;
}
if (!this.__notificationListeners[notificationType]) {
this.__notificationListeners[notificationType] = [];
}
var callbackAlreadyAdded = false;
this.__notificationListeners[notificationType].forEach(function (listenerEntry) {
if (listenerEntry.callback === callback) {
callbackAlreadyAdded = true;
return false;
}
});
function NotificationCenter(options) {
this.logger = options.logger;
this.errorHandler = options.errorHandler;
this.__notificationListeners = {};
utils.objectValues(enums.NOTIFICATION_TYPES).forEach(function(notificationTypeEnum) {
this.__notificationListeners[notificationTypeEnum] = [];
}.bind(this));
this.__listenerId = 1;
}