@iobroker/db-states-redis
Advanced tools
Comparing version 4.0.0-alpha.31-20211221-5d2e6cde to 4.0.0-alpha.32-20211225-2bedca92
@@ -788,3 +788,4 @@ /** | ||
* @param {String} id | ||
* @param callback | ||
* @param {function?} callback | ||
* @return {Promise<object>} | ||
*/ | ||
@@ -824,11 +825,3 @@ async getState(id, callback) { | ||
getStateAsync(id) { | ||
return new Promise((resolve, reject) => { | ||
this.getState(id, (err, res) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res); | ||
} | ||
}); | ||
}); | ||
return this.getState(id); | ||
} | ||
@@ -1032,6 +1025,12 @@ | ||
unsubscribe(pattern, subClient, callback) { | ||
/** | ||
* Unsubscribe pattern | ||
* @param {string} pattern | ||
* @param {object?} subClient | ||
* @param {(err: Error) => void?} callback | ||
* @return {Promise<void>} | ||
*/ | ||
async unsubscribe(pattern, subClient, callback) { | ||
if (!pattern || typeof pattern !== 'string') { | ||
typeof callback === 'function' && setImmediate(callback, `invalid pattern ${JSON.stringify(pattern)}`); | ||
return; | ||
return tools.maybeCallbackWithError(callback, `invalid pattern ${JSON.stringify(pattern)}`); | ||
} | ||
@@ -1045,3 +1044,3 @@ if (typeof subClient === 'function') { | ||
if (!subClient) { | ||
return typeof callback === 'function' && setImmediate(callback, tools.ERRORS.ERROR_DB_CLOSED); | ||
return tools.maybeCallbackWithRedisError(callback, tools.ERRORS.ERROR_DB_CLOSED); | ||
} | ||
@@ -1051,8 +1050,12 @@ | ||
this.log.silly(`${this.namespace} redis punsubscribe ${this.namespaceRedis}${pattern}`); | ||
subClient.punsubscribe(this.namespaceRedis + pattern, err => { | ||
if (!err && subClient.ioBrokerSubscriptions[this.namespaceRedis + pattern] !== undefined) { | ||
try { | ||
await subClient.punsubscribe(this.namespaceRedis + pattern); | ||
if (subClient.ioBrokerSubscriptions[this.namespaceRedis + pattern] !== undefined) { | ||
delete subClient.ioBrokerSubscriptions[this.namespaceRedis + pattern]; | ||
} | ||
typeof callback === 'function' && callback(err); | ||
}); | ||
return tools.maybeCallback(callback); | ||
} catch (e) { | ||
return tools.maybeCallbackWithRedisError(callback, e); | ||
} | ||
} | ||
@@ -1063,4 +1066,5 @@ | ||
* | ||
* @param pattern | ||
* @param {function} callback callback function (optional) | ||
* @param {string} pattern | ||
* @param {function?} callback callback function (optional) | ||
* @return {Promise<void>} | ||
*/ | ||
@@ -1067,0 +1071,0 @@ unsubscribeUser(pattern, callback) { |
{ | ||
"name": "@iobroker/db-states-redis", | ||
"version": "4.0.0-alpha.31-20211221-5d2e6cde", | ||
"version": "4.0.0-alpha.32-20211225-2bedca92", | ||
"engines": { | ||
@@ -8,3 +8,3 @@ "node": ">=12.0.0" | ||
"dependencies": { | ||
"@iobroker/db-base": "4.0.0-alpha.31-20211221-5d2e6cde", | ||
"@iobroker/db-base": "4.0.0-alpha.32-20211225-2bedca92", | ||
"ioredis": "^4.28.2" | ||
@@ -37,3 +37,3 @@ }, | ||
], | ||
"gitHead": "1360216c252693f9f7ed38e1ef385a5f4a4692d4" | ||
"gitHead": "8bb1199a14b696c069bf84f3b88147aa23e61a31" | ||
} |
@@ -7,3 +7,3 @@ # Redis DB states classes for ioBroker | ||
Copyright (c) 2014-2020 bluefox <dogafox@gmail.com>, | ||
Copyright (c) 2014-2021 bluefox <dogafox@gmail.com>, | ||
Copyright (c) 2014 hobbyquaker |
Sorry, the diff of this file is not supported yet
57173
1238
+ Added@iobroker/db-base@4.0.0-alpha.32-20211225-2bedca92(transitive)
+ Added@iobroker/js-controller-common@4.0.0-alpha.32-20211225-2bedca92(transitive)
- Removed@iobroker/db-base@4.0.0-alpha.31-20211221-5d2e6cde(transitive)
- Removed@iobroker/js-controller-common@4.0.0-alpha.31-20211221-5d2e6cde(transitive)