2012-04-21 04:56:40 +00:00
|
|
|
module.exports = function ( target, searchChannel, statChannel ) {
|
2012-04-18 05:05:32 +00:00
|
|
|
target.bus = {
|
2012-04-21 04:56:40 +00:00
|
|
|
subscriptions : [
|
|
|
|
|
searchChannel.subscribe( "search.init", target.init ).withContext( target ),
|
2012-04-18 05:05:32 +00:00
|
|
|
searchChannel.subscribe( "newTweets", target.processNewTweets ).withContext( target ),
|
2012-04-21 04:56:40 +00:00
|
|
|
statChannel.subscribe( target.namespace + ".getLatest",
|
|
|
|
|
function ( data, env ) {
|
|
|
|
|
console.log( "GET LATEST FOR: " + target.namespace );
|
|
|
|
|
statChannel.publish( {
|
|
|
|
|
topic : target.namespace,
|
|
|
|
|
data : target.lastStats,
|
|
|
|
|
correlationId : env.correlationId
|
|
|
|
|
} )
|
|
|
|
|
} ).withContext( target )
|
2012-04-18 05:05:32 +00:00
|
|
|
],
|
2012-04-21 04:56:40 +00:00
|
|
|
publishers : [
|
|
|
|
|
target.on( target.namespace, function ( data ) {
|
|
|
|
|
statChannel.publish( { topic : target.namespace, data : data } );
|
2012-04-18 05:05:32 +00:00
|
|
|
} )
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
|
return target;
|
|
|
|
|
};
|