All transaction-based ControlService methods now return promises directly, which makes it easier to integrate with other promises, is simpler and opens up new refactoring opportunities.

This commit is contained in:
Simo Kinnunen
2014-04-15 16:56:13 +09:00
parent 4270d9589c
commit f46540e51e
5 changed files with 23 additions and 29 deletions

View File

@@ -46,7 +46,7 @@ module.exports = function ControlServiceFactory(
function sendTwoWay(action, data) {
var tx = TransactionService.create(target)
socket.emit(action, channel, tx.channel, data)
return tx
return tx.promise
}
function touchSender(type) {
@@ -117,7 +117,7 @@ module.exports = function ControlServiceFactory(
socket.emit('storage.upload', channel, tx.channel, {
url: url
})
return tx
return tx.promise
}
this.uploadFile = function(files) {
@@ -135,7 +135,7 @@ module.exports = function ControlServiceFactory(
, file: files[0]
})
})
return tx
return tx.promise
}
this.install = function(options) {