Chris Small
Chris Small

Reputation: 363

breeze js save changes completes before saving

I have the following issue where the breeze js (1.4.2) SaveChanges method is processing the 'then' promise before the save operation completes.

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)
    })
}

I would have expected the 'then' part of the promise to execute once SaveChanges has fully completed? is this the expected behavior, can I detect when the save operation actually completes?

Upvotes: 1

Views: 505

Answers (1)

Chris Small
Chris Small

Reputation: 363

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();
}

Upvotes: 1

Related Questions