mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-06-23 14:01:35 +00:00
fix: add callback to pubsub.unsubscribe and test (#300)
This commit is contained in:
@ -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) => {
|
||||
|
Reference in New Issue
Block a user