mirror of
https://github.com/Hopiu/postal.js.git
synced 2026-04-21 07:11:06 +00:00
22 lines
No EOL
734 B
JavaScript
22 lines
No EOL
734 B
JavaScript
module.exports = function( target, searchChannel, statChannel ) {
|
|
target.bus = {
|
|
subscriptions: [
|
|
searchChannel.subscribe( "init", target.init ).withContext( target ),
|
|
searchChannel.subscribe( "newTweets", target.processNewTweets ).withContext( target ),
|
|
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 )
|
|
],
|
|
publishers: [
|
|
target.on( target.namespace, function( data ) {
|
|
statChannel.publish( { topic: target.namespace, data: data } );
|
|
} )
|
|
]
|
|
};
|
|
return target;
|
|
}; |