fix: add callback to pubsub.unsubscribe and test (#300)

This commit is contained in:
ebinks
2018-12-20 11:48:07 -05:00
committed by Jacob Heun
parent 8047fb76fa
commit 679d446daa
2 changed files with 40 additions and 22 deletions

View File

@ -33,7 +33,7 @@ module.exports = (node) => {
subscribe(callback)
},
unsubscribe: (topic, handler) => {
unsubscribe: (topic, handler, callback) => {
if (!node.isStarted() && !floodSub.started) {
throw new Error(NOT_STARTED_YET)
}
@ -43,6 +43,10 @@ module.exports = (node) => {
if (floodSub.listenerCount(topic) === 0) {
floodSub.unsubscribe(topic)
}
if (typeof callback === 'function') {
setImmediate(() => callback())
}
},
publish: (topic, data, callback) => {