subscribe

Subscribe/unsubscribe to multiple pubsubs

npm install subscribe
1 downloads in the last day
10 downloads in the last week
31 downloads in the last month

subscribe Build Status

Subscribe to multiple pub/subs.

Install

$ npm install subscribe

Usage

pubsub = require('pubsub')
subscribe = require('subscribe')

a = pubsub()
b = pubsub()
c = 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)

Subscribing For Once

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

a = pubsub()
b = pubsub()
c = 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)

npm loves you