subscribe

Subscribe/unsubscribe to multiple pubsubs

subscribe

Subscribe to multiple pub/subs.

$ npm install subscribe
pubsub = require('pubsub')
subscribe = require('subscribe')
 
= pubsub()
= pubsub()
= pubsub()
 
subscribe(a, b, c, function(updates){
 
    updates[0].pubsub
    // => a.onUpdate 
 
    updates[0].params
    // => 3, 4 
 
    updates[1].pubsub
    // => c.onUpdate 
 
    updates[1].params
    // => 5, 6 
 
})
 
a.publish(3, 4)
c.publish(5, 6)

subscribe.once fires the callback once all the pubsubs publish, for one time.

= pubsub()
= pubsub()
= pubsub()
 
once(a, b, c, function(){
 
    console.log('a, b, and c published')
 
})
 
a.publish(3, 4)
b.publish(5, 6)
c.publish(7, 8)