0.1.1 • Published 9 years ago

beam.js v0.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

beam.js

Build Status

beam.js is a distributed realtime broadcast emitter, built on top of redis.

Description

You can use beam to subscribe users to certain resources, such as database records or feeds. When those resources change, you can use beam to broadcast messages with details about the change to the users subscribed.

Example

// sets up beam to watch for messages
var beam = Beam({
    redis: redis.createClient(),
    subRedis: redis.createClient()
})

// follow events that sharon subscribed to.
var unfollow = yield beam.follow('sharon', function(msg){
    console.log(msg.resource)  // 'catpix'
    console.log(msg.body.some) // 'data'
    
    // when you're done unfollow
    unfollow();
})

// setup a driver without watching
var driver = Beam({ redis: redis.createClient() });

// subscribe sharon to catpix resource
yield driver.subscribe('sharon', 'catpix');

// broadcast change to catpix resource
yield driver.broadcast('catpix', {some: 'data'});

// unsubscribe sharon from catpix resource
yield driver.unsubscribe('sharon', 'catpix');

##API

0.1.1

9 years ago

0.1.0

9 years ago