Immediate Auto Saving with breeze

妖精的绣舞 提交于 2019-12-08 07:53:59

问题


I am implementing a form using Knockout and breezejs, I want to save each field when the user change the focus. So each change implies one save call to the server. The problem is that if the user does some changes while the previous save call is beeing done, the changes which weren't included in the first call, are restored to their original values when the server responds.

This is the configuration of my manager:

var manager = new breeze.EntityManager({
    serviceName : "/api/UserCentre/",
    saveOptions: new breeze.SaveOptions({allowConcurrentSaves: true})
});
manager.enableSaveQueuing(true);

回答1:


Remove the saveOptions and you'll be fine. "SaveQueuing" and allowConcurrentSaves are competing approaches.

I strongly discourage the use of allowConcurrentSaves as it can lead to unstable database inserts and updates. That's why it is defaults to false. It's really an advanced feature that I've never felt comfortable using.

"SaveQueuing" is a plug-in designed for your scenario. It ships as a separate JS file (breeze.savequeuing.js) as part of the samples. It queues client application save requests, ensuring that each request is issued only after the prior one completes. It's not foolproof by any means; their are edge conditions that can trip you. But it's the best approach we've discovered for auto-saving frequently as you are doing.



来源:https://stackoverflow.com/questions/16042574/immediate-auto-saving-with-breeze

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!