【发布时间】:2015-03-12 13:48:55
【问题描述】:
我试图在视图中显示在服务中运行的进程的进度。我的控制器调用第一个向第三方发送信息的服务,我通过调用第二个服务来记录每次发生这种情况,该服务进行计算以显示请求完成的百分比。
我有我想在第一个服务中更新的值,但我不确定如何用这个值更新视图。在工作完成之前,我不会返回控制器。
第一次服务
def batch(toCalculate,otherStuffDoneTotal otherData) {
def processPercentage
toCalculate.eachWithIndex(){ data, i ->
def otherMethod = otherMethod1(doStuffHere)
def progress = secondService.progressCalc(otherStuffDone, otherStuffDoneTotal, processPercentage)
}
}
二次服务
def progressCalc(otherStuffDoneTotal, otherStuffDone, processPercentage) {
def retItems
def retObjs = [:]
processPercentage = 100 / otherStuffDoneTotal * otherStuffDone
retItems = [processPercentage: processPercentage]
retObjs.putAll(retItems)
return(retOjbs)
}
如何让视图动态更新第一个服务的值(progress.progressPercentage)
【问题讨论】: