1

我有以下问题,在保存操作完成之前,微风 js (1.4.2) SaveChanges 方法正在处理“then”承诺。

save()
{
    this.manager.SaveChanges()
        .then(process);
}
function process()
{
    var baseUri = "api/DoServerProcessingOnNewData";
    $.getJSON(baseUri, data =>
    {
        // Save operation is still running, and server processes old data
        this.items(data)
    })
}

一旦 SaveChanges 完全完成,我会期望执行的“then”部分?这是预期的行为,我可以检测到保存操作何时真正完成吗?

4

1 回答 1

1

Solved issue, I had wrapped the save changes call in my data service layer. Calling the EntityManager.saveChanges directly correctly processes the promise.

// Don't do this, wrap the saveChanges method
public static saveChanges() 
{
    return DataService.EntityManager.saveChanges();
}
于 2013-09-26T08:19:24.817 回答