Split creating the defer and returning the promise

This commit is contained in:
David Cormier 2013-10-27 11:13:11 -04:00
parent 335ec46fc6
commit 02f51ad0df
1 changed files with 7 additions and 2 deletions

View File

@ -196,7 +196,7 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
var callbacks = {} var callbacks = {}
var currentCallBackId = 0; var currentCallBackId = 0;
var doSendWithCallback = function(message) { var createCallback = function(message) {
var defer = $q.defer(); var defer = $q.defer();
callbacks[++currentCallBackId] = { callbacks[++currentCallBackId] = {
time: new Date, time: new Date,
@ -204,7 +204,12 @@ weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers',
} }
callBackIdString = "(" + currentCallBackId + ")"; callBackIdString = "(" + currentCallBackId + ")";
doSend(callBackIdString + " " + message); doSend(callBackIdString + " " + message);
return defer.promise; return defer;
}
var doSendWithCallback = function(message) {
var cb = createCallback(message);
return cb.promise;
} }
// Sanitizes messages to be sent to the weechat relay // Sanitizes messages to be sent to the weechat relay