spire-io/jquery.spire.js — Issue #3: Optimize xhrs for publishing before subscribing
Author: jxson
Created: 2011-11-04 03:15:27+00:00
State: open

This will only make one call for the description request and one call for the sessions request

$.spire.messages.subscribe(channelName, callback);

$.spire.messages.publish({ channel: channelName
, content: 'wtf'
}, function(err, message){
console.log('message published: ', message.content);
});

This will make two

$.spire.messages.publish({ channel: channelName
, content: 'wtf'
}, function(err, message){
console.log('message published: ', message.content);
});

$.spire.messages.subscribe(channelName, callback);